class Demo {
public static void main(String[] args) {
Person p3 = new Person();
p3.name = "八嘎";
p3.speak();
Person p1 = new Person();
p1.name = "麦克";
p1.country = "美国";
Person p2 = new Person();
p2.name = "红杉";
p2.country = "中国";
p1.speak();
p2.speak();
}
}
class Person {
String name;
static String country = "日本";
public void speak() {
System.out.println(name + "..." + country);
}
}
通过图解 然后再通过我这段代码 希望你能很好的理解! 注意区分 static 和private的区别
|
|