标签:
1 public class Shuzuduixiangxingwei { 2 private int size; 3 private String name; 4 5 public int getSize(){ 6 return size; 7 } 8 public void setSize(int x){ 9 size = x; 10 } 11 public static void main(String[] args){ 12 Shuzuduixiangxingwei[] pets = new Shuzuduixiangxingwei[3]; 13 pets[0] = new Shuzuduixiangxingwei(); 14 pets[1] = new Shuzuduixiangxingwei(); 15 pets[2] = new Shuzuduixiangxingwei(); 16 17 for(int i=0 ;i<3;++i){ 18 pets[i].setSize(10+3*i); 19 } 20 for(int i=0;i<3;++i){ 21 System.out.println("狗狗"+i+"的size是:"+pets[i].getSize()); 22 } 23 } 24 }
标签:
原文地址:http://www.cnblogs.com/saimeco/p/5874850.html