No problem. Glad you got it figured out!
Type: Posts; User: KevinWorkman
No problem. Glad you got it figured out!
Yep! Maybe this will clear everything up:
public class Main {
public Main() {
System.out.println("In super constructor.");
}
That's pretty much exactly how I look at it. That might not be technically true (depending on when you decide that an instance "exists"), but it makes sense to me.
Sort of. Remember, in every constructor (that doesn't invoke another constructor like your no-args constructor does), there is an invisible call to super. So your code is really doing this:
public...
That's not my English, I just copied it from the JLS directly.
But basically what it's saying is that you can't use an instance variable before the super constructor has been called. Which means...
From the JLS: Classes
An explicit constructor invocation statement in a constructor body may not refer to any instance variables or instance methods declared in this class or any superclass, or...