您可以调用非静态方法,但是只能通过对象来调用。也就是说,您需要在给定对象上调用该方法。
您的主类也可以实例化,因此并非主类中的每个方法都必须是静态的。例如:
public class MainClass { int value; public void printValue() { System.out.println("" + value); } public static void main(String[] args){ MainClass o = new MainClass(); o.printValue(); }}


