public static void compareTo() {
String s1 = "Say";
String s2 = "Tell";
if (s1.compareTo(s2) > 0) {
System.out.println("s1 is Greater s2");
} else if (s1.compareTo(s2) < 0) {
System.out.println("s1 is Lesser s2");
} else if (s1.compareTo(s2) == 0) {
System.out.println("s1 is equal to s2");
} else if (s1.compareTo(s2) != 0) {
System.out.println("s1 is Not equal to s2");
} else if (s1.compareTo(s2) >= 0) {
System.out.println("s1 is GreaterThan to s2");
} else if (s1.compareTo(s2) <= 0) {
System.out.println("s1 is LessThan to s2");
}
}
No comments:
Post a Comment