62,614
社区成员
发帖
与我相关
我的任务
分享
public class Test{
private long a,b;
public Test(){}
public void setAB(long a,long b){
this.a=a;
this.b=b;
}
public long getA(){
return a;
}
public long getB(){
return b;
}
public static void main(String[] args) {
Test [] t1=new Test[5];
for(int i=0;i<t1.length;i++){
t1[i]=new Test();
}
t1[0].setAB(1, 2);
for(int i=1;i<t1.length;i++){
t1[i].setAB((t1[i-1].getA())+(t1[i-1].getB()), t1[i-1].getA()*t1[i-1].getB());
}
for(int i=0;i<t1.length;i++){
System.out.println("t1["+i+"]:a:"+t1[i].getA()+" b:"+t1[i].getB());
}
}
}