Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subclass overriding Superclass constructors

Status
Not open for further replies.

slobad23

IS-IT--Management
Jun 30, 2006
90
0
0
GB
Hello,

I am reading a book on Java at the moment and there is a section that has me very confused and I can't seem to find an answer online (and writing code to try and explain it to myself doesn't work - which may be because I don't understand it).

"If one class is inherited from another, each of them may have its own constructor explicitly defined" (got it)
"As with any other class method, a constructor of a subclass can override the constructor of a superclass" (CAN IT?)

I can't see how that works (or why you might want to do it)

Can anyone explain this?

Thanks
 
Of course it can, actually is very common. A Google search on "java override constructor" will show you a lot of examples like this one

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top