- class person
- {
- public static void main(String[] args)
- {
- //new PersonDemo();
- PersonDemo p =new PersonDemo(5);
- //p.setAge(5);
- //PersonDemo.run();
-
-
-
- }
- }
- class PersonDemo
- {
-
- private int age;
- public void setAge(int age) //我这里前面不加this,为什么还是能运行啊,毕老师不是说 成员变量跟局部变量同名时要加this以示区分吗??
- { //现在我的情况是加不加this都可以正常运行啊,大家看一下是什么问题。谢谢
- age = age;
- }
- String name ;
-
- PersonDemo()
- {
- System.out.println("age="+age+"..."+"name="+name);
- }
- PersonDemo(String name)
- {
- System.out.println("age="+age+"..."+"name="+name);
- }
- PersonDemo(int age)
- {
- System.out.println("age="+age+"..."+"name="+name);
- }
-
-
- }
复制代码 |