| Author |
public variables
|
Juhan Voolaid
Ranch Hand
Joined: Nov 18, 2003
Posts: 179
|
|
hello I'm having hard times with variables between the classes. I give you an example: So the "cannot resolve symbol" error comes in docMakerFrame class on this row: filename="test"; and in htmlMaker constructor. I don't understand why String filename is not accessable. Seems to me i give all the access rights.
|
 |
Darin Niard
Ranch Hand
Joined: Jun 08, 2004
Posts: 118
|
|
Classes don't share members with each other unless there is an inner/outer relationship, and of course in the case of inheritance. All classes DO have access to your "filename" variable, ie, docMaker.filename is available for use. [ August 03, 2004: Message edited by: Darin Niard ]
|
 |
Vijayendra V Rao
Ranch Hand
Joined: Jul 04, 2004
Posts: 195
|
|
Your code should be as follows:
|
Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
|
 |
Vijayendra V Rao
Ranch Hand
Joined: Jul 04, 2004
Posts: 195
|
|
The concept is, you access static members of a class using the class name. Now the variable filename is a static member and therefore, it will have to be accessed in other classes by using the name of the class in which it is declared. Hence the syntax: docMaker.filename; Got it?
|
 |
Juhan Voolaid
Ranch Hand
Joined: Nov 18, 2003
Posts: 179
|
|
|
thank you .. now it's very clear. It's been a while since i used java and oo. language now i remember.
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
|
Making attributes non-private always rubs me the wrong way. I use getters and setters when I need to access private variables.
|
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
|
 |
 |
|
|
subject: public variables
|
|
|