J
James
Here I face a strange thing when doing with String
str1,str2 is String and str1 and str2 is same string data (example like
str1="abc" and str2 is parameter in 1 method and assume it get "abc" string)
from this expression
if (str1==str2)
I get the "false" for result but when I use str1.equalsIgnoreCase(str2)
the result is true
anyone know why?
Here another one
** str3 is function parameter and assume it get "abc" in
String test=new String("abc");
String t1=new String(str3);
System.out.println((t1==test));
The result is false
so I want to ask, when put str1==str2 ,is that compare the value inside
string or it compare these 2 whether is same object?
str1,str2 is String and str1 and str2 is same string data (example like
str1="abc" and str2 is parameter in 1 method and assume it get "abc" string)
from this expression
if (str1==str2)
I get the "false" for result but when I use str1.equalsIgnoreCase(str2)
the result is true
anyone know why?
Here another one
** str3 is function parameter and assume it get "abc" in
String test=new String("abc");
String t1=new String(str3);
System.out.println((t1==test));
The result is false
so I want to ask, when put str1==str2 ,is that compare the value inside
string or it compare these 2 whether is same object?