title: Java Priority queue to sort integer inputs
body: <p>I'm trying to sort a sequence of positive integers which are inputted by the user with the use of Priority Queue. I'm not sure how to implement something so I'm wondering if anyone could help.This is what I have so far:</p>
  
  <pre><code>import java.util.PriorityQueue;
  import java.util.Scanner;
  
      public class priorityquene implements Comparable&lt;priorityquene&gt; 
      {
          final int priority;
          final String name;
  
          public priorityquene(int p, String n) 
          {
              priority = p;
              name = n;
          }
  
          public String toString() 
          {
              return priority + ", " + name;
          }
  
          public int compareTo(priorityquene other) 
          {
              return priority &lt; other.priority ? -1 : priority &gt; other.priority ? 1 : 0;
          }
  
          public static void main(String[] args) 
          {
              PriorityQueue&lt;priorityquene&gt; pq = new PriorityQueue&lt;priorityquene&gt;();
              Scanner input = new Scanner(System.in); 
              System.out.println("Please enter a positive integer: ");
              int num1 = input.nextInt();
              pq.add(new priorityquene(num1, " "));
              System.out.println("Please enter a positive integer: ");
              int num2 = input.nextInt();
              pq.add(new priorityquene(num2, " "));
              System.out.println("Please enter a positive integer: ");
              int num3 = input.nextInt();
              pq.add(new priorityquene(num3, " "));
              System.out.println("Please enter a positive integer: ");
              int num4 = input.nextInt();
              pq.add(new priorityquene(num4, " "));
              System.out.println("Please enter a positive integer: ");
              int num5 = input.nextInt();
              pq.add(new priorityquene(num5, " "));
  
              while (!pq.isEmpty())
                  System.out.println(pq.remove());
          }
      }
  </code></pre>
  
  <p>There are some things I'm not sure how to implement.
  How do i set it to accept an unlimited inputs and when a specific integer is input, say 0; it begins to sort from smallest to highest the inputs so far prior to 0?</p>