• 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
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok..that's a valid reason ..thanks manu
 
Campbell Ritchie
Sheriff
Pie
Posts: 50171
79
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic