Hi, everybody!
I need some help in this advanced topic.
I wrote the following code at Eclipse and doesn't show me any problem, so I can run the teste without problems.
But when I try to compile the classes using JDK (command line or
ant) I have the following error:
Test.java:9: incompatible types
found : java.util.Iterator<Person>
required: java.util.Iterator<IPerson>
return generaliza(iter);
The classes:
import java.util.*;
public class
Test {
public <T, S extends T> Iterator<T> generaliza(Iterator<S> iter) {
return null;
}
public Iterator Iterator<IPerson> test (Iterator<Person> iter) {
return generaliza(iter);
}
}
public interface IPerson {
public
String getName();
}
public class Person implements IPerson {
private String name;
public String getName() { return name;}
public void setName(String name) {this.name = name;}
}
The code works at Eclipse, but I have that error compiling in command line.
Do you know what happened!?!?!?!?!