This Java program is used to demonstrates comparison of two strings.
Example:
public class EqualCheck {
public static void main(String args[]){
String a = "AVATAR";
String b = "avatar";
if(a.equals(b)){
System.out.println("Both strings are equal.");
} else {
System.out.println("Both strings are not equal.");
}
if(a.equalsIgnoreCase(b)){
System.out.println("Both strings are equal.");
} else {
System.out.println("Both strings are not equal.");
}
}
}
Program Output:
0 Comments
If you have any doubts,please let me know