Mitsaki
Mitsaki

Reputation: 11

Call an overridden method in my main class

My code is like this... but there seems to be a problem when I call the overridden method createHome(). Here is a sample code:

public class Test extends SweetHome3D {
  public static void main(String [] args) {
    new Test().init(args);
    ***createHome();***
  }

  @Override
  public Home createHome() {
    Home home = super.createHome();
    // Modify home as you wish here
    return home;
  }
}

Upvotes: 0

Views: 143

Answers (1)

someguy
someguy

Reputation: 7334

I take it that code didn't compile? You are calling createHome() as if it's a static method.

public static void main(String [] args) {
  Test test = new Test();
  test.init(args);
  test.createHome();
}

Upvotes: 5

Related Questions