- class Person
- {
- private String name="haha";
- private int age;
- private static String country ="cn";
- Person(String name, int age)
- {
- this.name=name;
- this.age=age;
-
- }
-
- {
- System.out.println(name+".."+age);
- }
-
- public void setName(String name)
- {
- this.name=name;
-
- }
-
- public void speak()
- {
- System.out.println(this.name+"..."+this.age);
- }
- public static void showCountry()
- {
- System.out.println("country="+country);
- }
- }
- class PersonDemo
- {
- public static void main(String[] args)
- {
- Person p=new Person("zhangsan",20);
- }
- }
复制代码 大家好! 我想问下为什么打印结果是haha..0呢啊 ? 想不明白了 ! 麻烦大伙帮忙解答下! 跪谢了。
|