Ameem Shaik wrote:To me, it makes more sense to use coderanch, since the value is already marked final, and cannot be changed anyways.
As already said, public/private and final are orthogonal. But understand this: the final keyword only ensures that the variable can be assigned exactly once: either at declaration or in a constructor. It does NOT ensure that the state of the referred object cannot be changed. So if your final variable refers to a primitive or any immutable class (eg
String) it doesn't really matter. But consider, for example, that your variable refers to a JFrame. Making it public would allow another class to set the frame's size / location / visible properties and/or to add listeners like WindowListener / WindowFocusListener or worse still, to substitute the entire contents of the frame. All the final keyword would do is prevent the variable from being assigned to a new JFrame -- not much use, that.