Hello All, I am getting an error while running the below program. Java compiler javac 1.6.0_37
fails at compiling the following small program:
import java.util.*;
public class QueueTest {
public static void main( String args[] ) {
Queue<String> q = new LinkedList<String>();
}
}
The error message is:
QueueTest.java:5: incompatible types
found : java.util.LinkedList<java.lang.String>
required: Queue<java.lang.String>
Queue<String> q = new LinkedList<String>();
^
1 error
According to the documentation, LinkedList<E>
implements Queue<E>
, and this should compile. I was able to compile this code with javac 1.5.0_08
from here. Also, you can take the generics out of the picture and the problem remains the same (it won’t compile, even without generics).
My question is: anyone defends the position of this not being a bug?