Advertisement
mirena18uni

ListOfProducts

Feb 19th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class ListOfProducts {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner=new Scanner(System.in);
  7.  
  8. int n=Integer.parseInt(scanner.nextLine());
  9.  
  10. List<String> products=new ArrayList<>();
  11.  
  12.  
  13. for(int i=0; i<n; i++){
  14. String item=scanner.nextLine();
  15. products.add(item);
  16. }
  17. Collections.sort(products);
  18.  
  19. for(int i=0; i<products.size(); i++){
  20. System.out.printf("%d.%s%n",i+1, products.get(i));
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement