1. 程式人生 > >java練習---10

java練習---10

println code 分享 pub return .cn ges class es2017

技術分享

 1 package cn.zrjh;
 2 
 3 public class L {
 4 
 5          public int id;
 6         public String name;
 7         public int age;
 8         public String city;
 9         public String introduce() {
10             return  + id +  ":   在下  " + name + ", 芳齡" + age + ", 家住" + city ;
11         }  
12 13 14 }
 1 package cn.zrjh;
 2 
 3 public class Y {
 4 
 5     public static void main(String[] args) {
 6         L p1=new L();
 7         L p2=new L();
 8         L p3=new L();
 9         L p4=new L();
10         p1.id=100000;   p1.name="羅元昊";   p1.age=19;   p1.city="418";
11         p2.id=200000;   p2.name="孔宏旭";   p2.age=18;   p2.city="418";
12 p3.id=300000; p3.name="於星曄"; p3.age=19; p3.city="418"; 13 p4.id=400000; p4.name="黃浩然"; p4.age=19; p4.city="418"; 14 System.out.println(p1.introduce()); 15 System.out.println(p2.introduce()); 16 System.out.println(p3.introduce()); 17 System.out.println(p4.introduce());
18 19 } 20 21 }

技術分享

java練習---10