码迷,mamicode.com
首页 > 其他好文 > 详细

10.23

时间:2017-11-06 14:59:09      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:blog   ati   city   int   image   pack   return   com   ring   

package tyu;

public class Person {
    public int id;
    public String name;
    public int age;
    public String city;
    public String introduce() {
        String songs = null;
        return "我是" + id + ",叫" + name + ", 今年" + age + "岁, 来自" + city +"en "+songs;
    }  
    public Person(int id,String name,int age,String city) {
        this.id=id; 
        this.name=name;
        this.age=age;
        this.city=city;
    }
}

 

package tyu;

public class DemoPerson {
     public static void main(String[] args) {
            Person p1=new Person(110001,"刘备",43,"幽州涿郡涿县");
            Person p2=new Person(110002,"关羽",35,"河东郡解县");
            Person p3=new Person(110003,"张飞",25,"幽州涿郡");
            Person p4=new Person(110004,"诸葛亮",20,"徐州琅琊阳都");
           
            System.out.println(p1.introduce());
            System.out.println(p2.introduce());
            System.out.println(p3.introduce());
            System.out.println(p4.introduce());
     }
            

}

技术分享

10.23

标签:blog   ati   city   int   image   pack   return   com   ring   

原文地址:http://www.cnblogs.com/luhan7/p/7792799.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!