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 开发者_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();
}
精彩评论