public class Test{
public static void main(String[] args) {
// 调用Student类中的静态方法say
Student.Say();
// 调用Student类中的非静态方法eat
// 对象类型 对象名=对象值;
Student student = new Student();
student.eat();
//new Student().eat();
// 调用当前类里面定义的静态方法a
a();
}
// 和类一起加载的
public static void a(){
new Demo02().b();
}
// 类实例化之后存在
public void b(){
System.out.println("MyName");
}
}
public class Student {
// 静态方法 static
public static void Say(){
System.out.println("Hello");
}
// 非静态方法
public void eat(){
System.out.println("hungry");
}
}