Ivan18113

Task5

Apr 13th, 2021 (edited)
152
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package HomeWork_Programming;
  2.  
  3. import java.util.*;
  4.  
  5. public class Task5 {
  6.     public static void main(String[] args) {
  7.         String str = "";
  8.         Scanner scan = new Scanner(System.in);
  9.  
  10.         LinkedList ll = new LinkedList();
  11.         int n;
  12.  
  13.         while (scan.hasNextInt()){         //Input only numbers. Quit with any letter
  14.             n = scan.nextInt();
  15.             ll.add(n);          //Add to list
  16.         }
  17.            
  18.         Collections.sort(ll);      //sort the list
  19.         for (int i = 0; i < ll.size(); i++) {      //Output
  20.             if (i == ll.size()-1)
  21.                 System.out.print(ll.get(i));
  22.             else
  23.                 System.out.print(ll.get(i)+" <= ");
  24.             }
  25.  
  26.  
  27.     }//end of main
  28. }//end of class
  29.  
RAW Paste Data