document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.util.Scanner;
  2. class CompareStrings
  3. {
  4. public static void main(String args[])
  5. {
  6. String s1, s2;
  7. Scanner in = new Scanner(System.in);
  8.  
  9. System.out.println("Enter the first string");
  10. s1 = in.nextLine();
  11.  
  12. System.out.println("Enter the second string");
  13. s2 = in.nextLine();
  14.  
  15. if ( s1.compareTo(s2) > 0 )
  16. System.out.println("First string is greater than second.");
  17. else if ( s1.compareTo(s2) < 0 )
  18. System.out.println("First string is smaller than second.");
  19. else
  20. System.out.println("Both strings are equal.");
  21. }
  22. }
');