aspose file tools*
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
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: 40052
    
  28
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
 
subject: Why super can not be used in main() to call Super Class Behaviour or properties?