File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static variables and methods

 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in java a static method can access only static data members but main() is a static method
still it is accessing the instance data members by creating an object of other class.
how can it be possible?"
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can only access static data members without an object reference. But if you've got an object reference, non-static members and methods can be accessed via that.

E.g.

The distinction is that in non-static methods there is an implicit object reference (this), meaning you can access non-static members of the same object without a reference.

I'll move this to the Beginning Java forum, as it's more appropriate there.
 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic