| 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
|
 |
 |
|
|
subject: i dont understand super()
|
|
|