class Student{
String name;
public Student(String name){
this.name = name;
}
@Override
public String toString() {
return "Student [name = " + this.name + "]";
}
}
public class Demo{
public static void main(String[] args) {
List list = new ArrayList();
list.add(new Student("赵四"));
list.add(new Student("郭德纲"));
list.add(new Student("小沈阳"));
Iterator<Student> it = list.iterator();
while (it.hasNext()) {
it.next();
Student str = it.next();
System.out.println(str);
}
}
}
Exception in thread "main" java.lang.NoSuchMethodError: cn.itcast.demo01.Student.<init>(Ljava/lang/String;)V
at cn.itcast.demo01.Demo.main(Demo.java:121)
在class Student{上标记错误,我定义一个类还有错?
|
|