Hope this is the right place to ask
java certification question.
If not please let me know where I i should ask.
Any How here is my question.
I have this code which compiles fine.
Code -----------------------------
import java.util.*;
public class
Test {
public static void main() {
LinkedList<
String> x = new LinkedList<String>(); #1
x.add("one");
x.add("two");
x.add("Two");
System.out.println(x.poll());
}
}
Why does it compile? ArrayList does not have poll method. it doesn't inherit it either. I tried to read API several times. The poll method is in Queue,
so I think the line #1 can be only the line below.
Queue<String> x = new PriorityQueue<String>();
What am I missing here? Please explain.
This is my first time asking question here, so forgive me if this is not the right place to post a question.
Thanks in advance.
Anu Bhagat