<<< String charAt( ) and concatenation example | Index | String isEmpty( ) example >>> |
Code that compares strings
String lastName1 = "Smith"; String lastName2 = "Lee"; int sortResult = lastName1.compareToIgnoreCase(lastName2); if ( sortResult < 0 ) { System.out.println( lastName1 + " comes first." ); } else if ( sortResult == 0 ) { System.out.println( "The names are the same." ); } else { System.out.println( lastName2 + " comes first." ); }
<<< String charAt( ) and concatenation example | Index | String isEmpty( ) example >>> |