一个关于ArrayList类的问题
请看下面的程序
import java.util.*;
class studentElement extends Object
{
String name;
int score;
}
public class test
{
public static void main(String[] args)
{
ArrayList arraylist=new ArrayList();
studentElement stu=new studentElement();
Object stu2=new Object();
String a;
stu.name="monkey";
stu.score=90;
arraylist.add(stu);
stu2=arraylist.get(0);
a=stu2.name;
System.out.println(a);
}
}
为什么在a=stu2.name;处就出错呢?
另外 我要用ArrayList时是不是必须要让我自己的那个类studentElement继承Object类啊?
各位高手能否给个解答啊,谢了