I have two string and when i compare these two strings in java using equals method it says has not equal. Not sure why it has to say not equal. Can somebody please help me on issue and advise me here.
Below is the code snippet.
public class Ex9 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//String str1_ui = "In Network: $1,550 individual; $3,875 family; includes deductible; copays do not apply; in and out of network combined Out of Network: $2,350 individual; $5,875 family; includes deductible; copays do not apply; in and out of network combined";
//String str2_excel = "In Network: $1,550 individual; $3,875 family; includes deductible; copays do not apply; in and out of network combined Out of Network: $2,350 individual; $5,875 family; includes deductible; copays do not apply; in and out of network combined";
String str1_ui = "deductible; copays";
String str2_excel = "deductible; copays";
System.out.println("Length of str1_ui : "+str1_ui.trim().length());
System.out.println("Length of str2_excel : "+str2_excel.trim().length());
if(str1_ui.trim().equalsIgnoreCase(str2_excel.trim()))
{
System.out.println("Both are equal");
}
else
{
System.err.println(" Both are not equal");
}
}
}
Console output