Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Order of things on construction

  Asked By: Ernesta    Date: Nov 10    Category: Java    Views: 669
  

I'm having a bit of a problem. I have a virtual base class, call it part:

abstract class part {
part() {
doSomething();
}

abstract void doSomething();
}

I have a subclass, bolt, another class, location, is used in
doSomething.

public class bolt extends part {
public location lct=new location();

bolt() {
super();
}

public void doSomething() {
lct.bin( 22 );
doOtherStuff();
}
}

When I run this I get null pointer errors. It looks like
super is getting called before the new location() call gets
made. Is this correct? Is there a way to work around this?
I've considered doing my "new location" inside of doSomething
but that just doesn't feel right and is a bit confusing to
the reader.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Order of things on construction Or get search suggestion and latest updates.




Tagged: