I have been reading up on coding practices that could cause memory leaks and one of them is using static variables or classes,
Since they will remain for lifetime of the application.
Question that comes to my mind is that:- usually when we define a constants file its mostly a class and all the strings are defined as :
public static final String ABC="Constant1";
Now another way of defining the same string as a constant would be to have an interface and within the interface you define
String ABC="Constant1";
Would using an interface to define constants rather than have a class with static definitions make any difference in concerns with memory saving?
Appreciate all your inputs
shivendra tripathi
Ranch Hand
Joined: Aug 26, 2008
Posts: 263
posted
0
Whenever you define a variable in interface by default it is public static and final. So I don't see any difference in both the cases.