aspose file tools*
The moose likes Beginning Java and the fly likes use of super() in non inherited class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "use of super() in non inherited class" Watch "use of super() in non inherited class" New topic
Author

use of super() in non inherited class

Rajesh Veluchamy
Ranch Hand

Joined: Jan 15, 2008
Posts: 47
In the below code there is a super() in class which is not a child class(there is no extends)

Then what is the use of that "super();"




-Rajesh.V<br /> Software Consultant
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Then what is the use of that "super();"

Think twice Don't Java classes all extend the same class ?
I don't find the super() particularly useful here though. If you don't write it, the compiler will implicitly put it for you anyway.

The Java Language Specification
8.8.7 Constructor Body
The first statement of a constructor body may be an explicit invocation of another constructor of the same class or of the direct superclass. If a constructor body does not begin with an explicit constructor invocation and the constructor being declared is not part of the primordial class Object, then the constructor body is implicitly assumed by the compiler to begin with a superclass constructor invocation "super();", an invocation of the constructor of its direct superclass that takes no arguments.


[My Blog]
All roads lead to JavaRanch
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Hi,
As already said above, "that super()" may not be useful, and just to add on,
all Java classes are CHILDREN of java.lang.Object.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Amit Ghorpade:
all Java classes are CHILDREN of java.lang.Object.


that's what I thought to point you regarding to the concept super class,

here is tutorial for Object as a Superclass and Using the Keyword super provided by Sun.

These might help you in that.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of super() in non inherited class