/** This program prints the largest of two strings. */ import java.util.Scanner; public class PrintLargestString { public static void main( String[] args ) { // Get the strings. Scanner inp = new Scanner(System.in); System.out.print("Enter the first string: "); String firstStr = inp.next(); System.out.print("Enter the second string: "); String secondStr = inp.next(); // Determine the largest string. String largestStr; if( firstStr.compareTo(secondStr) >= 0 ) { largestStr = firstStr; } else { largestStr = secondStr; } // Print the largest string System.out.println( largestStr ); } }