wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes i dont understand super() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "i dont understand super()" Watch "i dont understand super()" New topic
Author

i dont understand super()

neil harper
Greenhorn

Joined: Oct 30, 2010
Posts: 14
super() calls the superclass constructor correct? in what situation would this be beneficial?
Martin Caminoa
Greenhorn

Joined: Oct 25, 2010
Posts: 5
It's utile to call the constructor method from superclass because constructors are not inherited
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See Java Tutorials - Using the Keyword super for details and examples.

Note that "if a constructor does not explicitly invoke a superclass constructor, the Java compiler automatically inserts a call to the no-argument constructor of the superclass." So if the no-argument constructor is what you want, there isn't a need to insert "super()" without arguments.

On the other hand, if you want to invoke a superclass constructor with arguments, then you must explicitly call super(args...) from the subclass constructor.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i dont understand super()
 
Similar Threads
The winners...
WA #1.....word association
regarding this or super call in constructors
can I use sdk 1.5?
clared SCWCD with 91%