Advertisement
cd62131

Sort Numeric

Jan 15th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.53 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class SortNumeric {
  7.   public static void main(String[] args) {
  8.     Scanner in = new Scanner(System.in);
  9.     List<Integer> pool = new ArrayList<Integer>();
  10.     while (true) {
  11.       System.out.print("? ");
  12.       int a = new Integer(in.nextLine());
  13.       if (a == -1) break;
  14.       if (a < 0) continue;
  15.       pool.add(a);
  16.     }
  17.     in.close();
  18.     Collections.sort(pool);
  19.     System.out.println(pool);
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement