This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Why super can not be used in main() to call Super Class Behaviour or properties? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why super can not be used in main() to call Super Class Behaviour or properties?" Watch "Why super can not be used in main() to call Super Class Behaviour or properties?" New topic
Author

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

isha krishnan
Ranch Hand

Joined: Nov 10, 2008
Posts: 50
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

Joined: May 22, 2012
Posts: 44
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

Joined: Nov 10, 2008
Posts: 50
ok..that's a valid reason ..thanks manu
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44031
    
  33
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Why super can not be used in main() to call Super Class Behaviour or properties?
 
It's not a secret anymore!