title: Using GenericQueue to print words input by user in reverse order. Java
body: <p>I am confused with the GenericQueue. With only add elements (queue.enqueue) and remove elements (queue.dequque) from it, how can I display a reverse words from user input?</p>
  
  <p>To be more specific, I have the following code for java.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class displayreverse {
  public static void main(String[] args) {
          Scanner input = new Scanner(System.in);
          GenericQueue&lt;String&gt; queue = new GenericQueue&lt;String&gt;();
          System.out.print("Enter some words: ");
          String words = input.nextLine();
  
          queue.enqueue(words);
          System.out.println(queue);
  
      }
  }
  </code></pre>
  
  <p>The output will look like this:</p>
  
  <pre><code>run:
  Enter some words: who are you
  Queue; [who are you]
  </code></pre>
  
  <p>How will I use the GenericQueue in order for it to display it in reverse order? The output should be like: "you are who" instead of "who are you"</p>
  
  <p>My GenericQueue class is as follows:</p>
  
  <pre><code>public class GenericQueue&lt;E&gt; {
      private java.util.LinkedList&lt;E&gt; list = new java.util.LinkedList&lt;E&gt;();
              public void enqueue(E e){
                  list.addLast(e);
              }
              public E dequeue(){
                  return list.removeFirst();
              }
              public int getSize(){
                  return list.size();
              }
              public String toString(){
                  return "Queue; " + list.toString();
              }
  }
  </code></pre>
  
  <p>Thanks...</p>