This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes supertype constructor 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "supertype constructor " Watch "supertype constructor " New topic
Author

supertype constructor

preeti khane
Ranch Hand

Joined: Mar 12, 2003
Posts: 93

It says compile time error - cannot reference Q43.y until supertype constructor has been called
I am not sure I understand the error... Can someone explain? Does it mean super() has to be called or that a base class should exist for this class
Praveen Kumar Mathaley
Ranch Hand

Joined: Apr 14, 2003
Posts: 45
According to jls, one cannot access instance variables in the calls to super constructors as still they are not intialized( follow the object creation thread flow.)
in the given class the no argument constructor is calling the argument constructor, so still the super constructor has not been called yet at the line this(y) hence the compilation error that cannot reference y before call to supertype constructor.
 
 
subject: supertype constructor
 
Similar Threads
this operator
help with go4java again
Calling constructor
exception
on constructor