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

Why super can not be used in main() to call Super Class Behaviour or properties?

 
isha krishnan
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All,

Why super can not be used in main() to call Super Class Behaviour or properties?
We can super.methodname()/super.variablename() in any method to call super behaviour/attributes.Why this can not be done in main()?


Thanks
 
Manu Somasekhar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Isha,
Your main method is static. You can not access non static variables from static methods which in this case is your super class.
 
isha krishnan
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok..that's a valid reason ..thanks manu
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Static members of the class belong to the class, not to the object. They are actually outside any objects, do it would be nonsense to write this, or super.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic