public class StudentDemo {
private String name;
private int age;:lol:lol
public StudentDemo() {}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public void show() {
System.out.println("名字:"+name +"------>年龄:"+ age);
}
public class ArrayStudent {
public static void main(String[] args) {
String[] name={"李白","杜甫","王安石","辛弃疾","李清照"};
StudentDemo[] st=new StudentDemo[5];
int[] age={110,120,119,250,99};
//StudentDemo[] s=new StudentDemo[st.length];
for (int i = 0; i < st.length; i++) {
st[i]=new StudentDemo();
st[i].setName(name[i]);
st[i].setAge(age[i]);
}
for (int i = 0; i < age.length; i++) {
st[i].show();
}
}
}: |
|