File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Private Access Modifier

 
Kalai Selvan
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,



The above code compiles without any problem. According to me it should
not compile since in the 2nd line of main method since a private variable is directly accessed using object reference. And also the declaration of i is also making forward referencing to the j variable, which should also give an compilation error. Can any one give me proper explanation.......

Thanks and Regards,
Kalai Selvan T.
[ November 03, 2004: Message edited by: Kalai Selvan ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All your code is in one class, so access modifiers do not make any difference. A class can always see all of its own members: fields and methods.

Many types of "forward reference" are perfectly OK in Java. See the Language Specification for more details, if you care about them.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic