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

10.23作业 刘惠惠

时间:2017-11-06 13:11:27      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:void   http   public   name   logs   含义   main   ima   es2017   

package cn.person.www;
 
public class Prson {
     
    public int id;
    public String name;
    public int age;
    public String city;
    public String introduce() {
        return "我是" + id + "号, 叫  " + name + ", 今年" + age + "岁了, 来自" + city ;
    } 
 public person(int id,String name,int age,String city) {
     this.id=id; //this关键字,表达的含义是当前对象 .表示当前对象的某个调用
     this.name=name;
     this.age=age;
     this.city=city;
 }
         
}

  

package cn.person.www;
 
public class Demoperson {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        person p1=new person(001,"刘备",40,"北京");
        person p2=new person(002,"关羽",37,"北京");
        person p3=new person(003,"张飞",45,"北京");
        person p4=new person(004,"诸葛亮",25,"北京");
         
        System.out.println(p1.introduce());
        System.out.println(p2.introduce());
        System.out.println(p3.introduce());
        System.out.println(p4.introduce());
         
    }
 
}

  技术分享

10.23作业 刘惠惠

标签:void   http   public   name   logs   含义   main   ima   es2017   

原文地址:http://www.cnblogs.com/huiiuh/p/7792549.html

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