Hi all,
The code below gives me a compiler error
Compiling 1 source file to Main.java:36: cannot find symbol
symbol : method add(Animal)
location: interface java.util.List<capture of ? super Dog>
l.add(new Animal());
-----------------------------------------
I cant understand the reason for it.Please help me.
-------------------------------------------------------------
import java.util.*;
class Animal{
Animal(){}
}
class Dog extends Animal//implements Comparable<Dog>
{
private
String name;
Dog(String d)
{ this.name = d;}
public String toString()
{return this.name;
}
public boolean equals(Object o)
{
if( (o instanceof Dog) && ( ((Dog)o).name == this.name ) )
return true;
return false;
}
}
public class Main extends
Thread {
public static void main(String argv[])
{
List<? super Dog> l = new ArrayList<Animal>();
l.add(new Animal());
}
}