开发者

Call an overridden method in my main class

开发者 https://www.devze.com 2023-03-29 20:38 出处:网络
My code is like this... but there seems to be a problem when I call the overridden method createHome(). Here is a sample code:

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 开发者_StackOverflowhome = super.createHome();
    // Modify home as you wish here
    return home;
  }
}


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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号