“Cannot instantiate the type…”

前端 未结 6 2065
后悔当初
后悔当初 2021-01-03 19:44

When I try to run this code:

import java.io.*;
import java.util.*;

public class TwoColor
{
    public static void main(String[] args) 
    {
         Queue&         


        
6条回答
  •  长发绾君心
    2021-01-03 20:22

    You can use

    Queue thequeue = new linkedlist();
    

    or

    Queue thequeue = new Priorityqueue();
    

    Reason: Queue is an interface. So you can instantiate only its concrete subclass.

提交回复
热议问题