运行之后会出现
Exception in thread "main" java.lang.NoSuchMethodError: Person.<init>(Ljava/lang/String;I)V
at EnumTest.main(EnumTest.java:9)- public class EnumTest
- {
- public static void main(String[] args) //throws IOException
- {
- ArrayList al = new ArrayList();
- al.add(new Person("lisi01",25));
- al.add(new Person("lisi02",43));
- al.add(new Person("lisi03",24));
- al.add(new Person("lisi04",17));
- Iterator it = al.iterator();
- while(it.hasNext())
- {
- Person p = (Person)it.next();
- System.out.println(p.getName()+p.getAge());
- }
- }
- }
- class Person
- {
- private String name;
- private int age;
- Person(String name,int age)
- {
- this.name = name;
- this.age = age;
- }
- public String getName()
- {
- return name;
- }
- public int getAge()
- {
- return age;
- }
- }
复制代码
|
|