S
SaravanaKumar
Hi is there any use in instantiating a class with all static members.
For example Consider a class
//start class dec
public class MyConstants{
public static final int CHECKING = 0;
public static int SAVINGS = 1;
public static final String getAString(){
return "some SampleString";
}
}
//end class
Normally this class can be used like MyConstants.CHECKING,
MyConstants.getAString etc.,
But some of the clients instantiate this class like
MyConstants mc = new MyConstants();
and use the variables like mc.CHECKING, mc.getAString().,
My Questions are
1. By Instantiating the object will it improve the performance of the
client classes? If so how?
2. Is this a good code design to use a constant class like this?
Thanks,
SaravanaKumar
For example Consider a class
//start class dec
public class MyConstants{
public static final int CHECKING = 0;
public static int SAVINGS = 1;
public static final String getAString(){
return "some SampleString";
}
}
//end class
Normally this class can be used like MyConstants.CHECKING,
MyConstants.getAString etc.,
But some of the clients instantiate this class like
MyConstants mc = new MyConstants();
and use the variables like mc.CHECKING, mc.getAString().,
My Questions are
1. By Instantiating the object will it improve the performance of the
client classes? If so how?
2. Is this a good code design to use a constant class like this?
Thanks,
SaravanaKumar