• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

public variables

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code should be as follows:

 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you .. now it's very clear. It's been a while since i used java and oo. language now i remember.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Making attributes non-private always rubs me the wrong way. I use getters and setters when I need to access private variables.
 
reply
    Bookmark Topic Watch Topic
  • New Topic