package org.newer.edit.review;
import java.util.ArrayList;
import java.util.List;
public class EditData {
static List<Student> arrStudent = new ArrayList<Student>();
static Student stu = new Student();
public List<Student> stuAdd(){
return arrStudent;
}
public static void main(String[] args) {
Student stu = new Student(1,"学生一",18);
Student stu1 = new Student(2,"学生二",19);
Student stu2 = new Student(3,"学生三",20);
for (int i = 0; i < 3 ;i++) {
// 报错:无法转型。 String cannot be cast to Student;
arrStudent.add((Student)(Object)("stu"+(i==0?"":i)));
}
}
// 我就是想通过对字符串的操作,让字符串的值跟stu/stu1/stu2相同,然后,将他们new 的对象存储到数组中去。
} |
|