javaimportlinked-list

LinkedList cannot be resolved to a type


import java.util.LinkedList;

public class QueueUsingLinkedList{

  public static void main (String args []){

     Queue<Info> qe = new LinkedList<>();

  }
}

When I am importing the LinkedList I am getting this error

The import java.util.LinkedList cannot be resolved

LinkedList using Queue or even trying to create a simple LinkedList but it showing me the error

LinkedList cannot be resolved to a type

but i dont know why only LinkedList is throwing the error

I tried to re-import. Also I checked the syntax.
and compile the code "java ClassName.java"


Solution

  • Assuming that Info is one of your classes, and that it exists, I did it this way and received no errors. A LinkedList can be the constructor for a Queue.

    Also, command line compilation is javac not java. Hoping that is just a typo.

    import java.util.LinkedList;
    import java.util.Queue;
    
    public class QueueUsingLinkedList{
    
      public static void main (String args []){
    
         Queue<Info> qe = new LinkedList<>();
    
      }
    }