package studentDemo;
public class student {
private String name;
private int age;
public student() {
super();
}
public student(String name, int age) {
super();
this.name = name;
this.age = age;
}
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;
}
}
//前面的是一个学生类
package studentDemo;
public class studentTest {
public static void main(String[] args) {
student s1=new student("张三",10);
student s2=new student("李四",11);
student s3=new student("王五",12);
student s4=new student("赵六",13);
student s5=new student("刘七",14);
student []stu={s1,s2,s3,s4,s5};
for (int i = 0; i < stu.length; i++) {
System.out.println(stu[i].getName()+"----"+stu[i].getAge());
}
}
}
|
|