标签:r++ ast static 数据 count private style tag roo
1 package JavaStatic; 2 3 public class Demo01 { 4 public static void main(String[] args){ 5 Stdunt one = new Stdunt("郭靖",18); 6 one.room ="大数据一班"; 7 System.out.println("姓名:" + one.getName() + ",年龄" + one.getage()+ one.room+",学号:" + one.getid()); 8 Stdunt tow = new Stdunt("黄蓉",16); 9 System.out.println("姓名:" + tow.getName() + ",年龄" + tow.getage()+ tow.room+",学号:" + tow.getid()); 10 } 11 }
1 package JavaStatic; 2 3 public class Stdunt { 4 private int id; //学号 5 private static int idCounter = 000; 6 private String name;//姓名 7 private int age;//年龄 8 static String room; 9 //无参构造 10 public Stdunt() { 11 this.id = idCounter++; 12 } 13 //有参构造 14 public Stdunt (String name,int age){ 15 this.name = name; 16 this.age = age; 17 this.id = ++idCounter; 18 } 19 public void setName (String name){ 20 this.name = name; 21 } 22 public String getName(){ 23 return name; 24 } 25 26 public void setage (int age){ 27 this.age = age; 28 } 29 public int getage(){ 30 return age; 31 } 32 public void setid (int id){ 33 this.id = id; 34 } 35 public int getid (){ 36 return id; 37 } 38 }
标签:r++ ast static 数据 count private style tag roo
原文地址:https://www.cnblogs.com/bingquan1/p/12535081.html