import java.util.*;
public class String_Compare_Ignore_Case
{
public static void main()
{
Scanner sc = new Scanner(System.in);
String s1, s2;
int l1, l2, i, flag=1;
System.out.println("Enter 2 strings:");
s1 = sc.nextLine();
s2 = sc.nextLine();
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
l1 = s1.length();
l2 = s2.length();
if(l1==l2)
{
for(i=0;i<l1;i++)
{
if(s1.charAt(i)!=s2.charAt(i))
{
flag = 0;
break;
}
}
if(flag==1)
System.out.println("The strings are equal.");
else
System.out.println("The strings are not equal.");
}//end of if
else
System.out.println("The strings are not equal.");
}
}
Write a program in Java to input two strings and print whether they are equal or not. Irrespective of their cases.
Programming