未调用静态方法 Java
Static method not being called Java
既然main方法是静态的,应该可以静态调用。因此,我使用:
package prototype.server.main;
import javax.swing.JFrame;
import prototype.server.main.gui.Swing;
public class Runtime {
public static void main(String[] argv) {
Swing swing = new Swing(true, argv[0]);
@SuppressWarnings("unused")
JFrame maingui = swing.getGuiFrame();
}
}
作为静态主代码,然后调用使用:
import prototype.server.main.Runtime;
public class Main {
Runtime.main(new String{"f"});
}
调用静态方法,但 Eclipse 报错。请帮助并提前谢谢你。
我们需要修复两个错误;
import prototype.server.main.Runtime;
public class Main {
// add constructor, or method that you can call another method
// or make this static { ... } block that fits you
public Main() {
//do not forget [] for array
Runtime.main(new String[]{"f"});
}
}
既然main方法是静态的,应该可以静态调用。因此,我使用:
package prototype.server.main;
import javax.swing.JFrame;
import prototype.server.main.gui.Swing;
public class Runtime {
public static void main(String[] argv) {
Swing swing = new Swing(true, argv[0]);
@SuppressWarnings("unused")
JFrame maingui = swing.getGuiFrame();
}
}
作为静态主代码,然后调用使用:
import prototype.server.main.Runtime;
public class Main {
Runtime.main(new String{"f"});
}
调用静态方法,但 Eclipse 报错。请帮助并提前谢谢你。
我们需要修复两个错误;
import prototype.server.main.Runtime;
public class Main {
// add constructor, or method that you can call another method
// or make this static { ... } block that fits you
public Main() {
//do not forget [] for array
Runtime.main(new String[]{"f"});
}
}