Venciity

[SoftUni Java] Introduction - 08.SortArrayOfStrings

May 6th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class SortArrayOfStrings {
  6.  
  7.     public static void main(String[] args)
  8.     {
  9.        
  10.         Scanner scan = new Scanner(System.in);
  11.         int n = scan.nextInt();
  12.        
  13.         String[] allWords = new String[n];
  14.        
  15.         scan.nextLine();
  16.         for (int i = 0; i < n; i++)
  17.         {
  18.             allWords[i] = scan.nextLine();
  19.         }
  20.        
  21.         Arrays.sort(allWords);
  22.         System.out.println();
  23.        
  24.         for(int i=0;i<n;i++)
  25.         {
  26.                 System.out.println(allWords[i]);
  27.         }
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment