- class Demo {
- public static void main(String[] args) {
- Person p1 = new Person();
- p1.name = "麦克";
- p1.country = "美国";
- Person p2 = new Person();
- p2.name = "红杉";
- p2.country = "韩国";
- p1.speak();
- p2.speak();
- }
- }
- class Person {
- private static String 中国;
- String name;
- static String country = 中国;
- public void speak() {
- System.out.println(name + "..." + country);
- }
- }
复制代码
运行结果:
麦克...韩国
红杉...韩国 |
|