Link to home
Start Free TrialLog in
Avatar of jayz_smith
jayz_smith

asked on

private static final

hi all, please tell me why to use private static final in front of variable ? If the variable is final, its value will be constant in that class. So what is the need of static keyword because if the variable is static, it has only one instance throughout the class.... Please explain.
ASKER CERTIFIED SOLUTION
Avatar of nordtorp
nordtorp
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jayz_smith
jayz_smith

ASKER

@ nordtorp :  Thanks for the wonderful link. Only one question.  " Before Java can create an instance of a class, it must first load and initialize that class. One step of class initialization is assigning values to all its static fields " this is what the link says. But my question to you is, what if there is no static fields in the class ? how would that class get initialize by java ?
perfect answer
It just says that one step of class initialization is assigning values to all its static fields, if there are no static fields, it does not need to assign anything.