Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

public class Lan{
    public static void main(String []agrs){
        /*
        Person p1=new Person();
        p1.age=8;
        p1.Test();
        System.out.println("第一个为"+p1.age);
        创建这一个的时候就不行,提示找不到符号,在“Person p1=new Person()”的new这里提示的,去掉可就没问题。。
        */
        Person p2=new Person(7,"小五");
        p2.Test();
        p2.jisuan();
        System.out.println("第二个为"+p2.age);
    }
}
class Person{
    int age;
    String name;
    public void jisuan()
    {
        int i=2;
        System.out.println(i);
    }
    public void Test(){
        System.out.println("做测试1");
    }
    Person(int age,String name){
        this.age=age;
        this.name=name;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
400 views
Welcome To Ask or Share your Answers For Others

1 Answer

没写默认构造器啊


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...