warfighter67

String Sorter

Oct 3rd, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. String[] str = new String[4];
  2. int numPass = str.length();
  3. Scanner scan_in = new Scanner(System.in);
  4.  
  5. for(int x=0; x<numPass; x++;)
  6. {
  7.     str[x] = scan_in.nextLine();
  8. }
  9.  
  10. for(int pass=1; pass < numPass; pass++)
  11. {
  12.     for(int i=0; i < numPass-pass; i++)
  13.     {
  14.         if(str[i].compareToIgnoreCase(str[i+1] < 0)
  15.         {
  16.             int temp = str[i];  str[i] = str[i+1];  str[i+1] = temp;
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment