How do I instantiate a Queue object in java?

后端 未结 8 750
南旧
南旧 2020-11-29 16:39

When I try:

Queue q = new Queue();

the compiler is giving me an error. Any help?

Also, if I want to i

8条回答
  •  隐瞒了意图╮
    2020-11-29 17:19

    Queue is an interface; you can't explicitly construct a Queue. You'll have to instantiate one of its implementing classes. Something like:

    Queue linkedList = new LinkedList();
    

    Here's a link to the Java tutorial on this subject.

提交回复
热议问题