programming-examples/java/Basics/How to compare two strings.java
2019-11-18 14:44:36 +01:00

10 lines
395 B
Java

public class StringCompareEmp {
public static void main(String args[]) {
String str = "Hello World";
String anotherString = "hello world";
Object objStr = str;
System.out.println( str.compareTo(anotherString) );
System.out.println( str.compareToIgnoreCase(anotherString) );
System.out.println( str.compareTo(objStr.toString()));
}
}