3nigmatic
asked on
Class wide variables
Hey,
Dow do I declare variables so that they can be accessed by all classes or by at least one other class ?
Kind Regards,
Dow do I declare variables so that they can be accessed by all classes or by at least one other class ?
Kind Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cool, thanks, i was kind of close, I didnt have the static bit.
What does the "final" keyword do ?
What does the "final" keyword do ?
Well,
final means that you can't change the value. It is *fixed*. It is good if you want to have a kind like constant where the value will not change in your app.
public static final String APPLN_SERIES = "PL"; means "Hey Java compiler, create one String that belongs to the class of Constants (static), make it unchangeable (final) and it should be public so it is accessible from other class. Thanks in advanced" :).
final means that you can't change the value. It is *fixed*. It is good if you want to have a kind like constant where the value will not change in your app.
public static final String APPLN_SERIES = "PL"; means "Hey Java compiler, create one String that belongs to the class of Constants (static), make it unchangeable (final) and it should be public so it is accessible from other class. Thanks in advanced" :).
ASKER
I thought that might be what it stood for, but always helpful to check these things.
Thanks for the help.
**Extra 75 points added for the additional info**
Thanks for the help.
**Extra 75 points added for the additional info**
:).
Glad I could help.
Glad I could help.
David