Problem:
Reason:
Static methods can not call non-static methods own definition of
resolve:
1. Change the non-static methods as static methods, plus static void before the add method of
the object 2 can be instantiated in the main non-static method in the main method
the following example:
public class Demo01 {
public static void main(String[] args) {
//静态方法的调用
Demo01.add();
//非静态方法的调用
Demo01 demo=new Demo01();//实例化对象,再调用方法
demo.get();
}
//静态方法
public static void add(){
System.out.print("静态方法");
}
//非静态方法
public void get(){
System.out.print("非静态方法");
}
}