Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Order of things on construction

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

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

abstract class part {
part() {

abstract void doSomething();

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

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

bolt() {

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

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.



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.