Link to home
Start Free TrialLog in
Avatar of 3nigmatic
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,
Avatar of suprapto45
suprapto45
Flag of Singapore image

Do you mean create one variable in one class A and this variable is accessible from other classes such as class B, C, D and so on?

David
ASKER CERTIFIED SOLUTION
Avatar of suprapto45
suprapto45
Flag of Singapore 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 3nigmatic
3nigmatic

ASKER

Cool, thanks, i was kind of close, I didnt have the static bit.

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" :).
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**
:).

Glad I could help.