Java静态方法和非静态方法之间的关系
- 2020 年 12 月 14 日
- 筆記
public class Demo2 {
public static void main(String[] args) {
//实例化这个类 new
//对象类型 对象名 = 对象值
Student student = new Student();
student.say();
}
public class Student {
//非静态方法
public void say(){
System.out.println("学生说话了");
}
}-
静态方法不能调用非静态方法,反之可以