from marcus mock exam#1
Given the following code, what
test would you need to put in place of the comment line?
//place test here
to result in an output of
Equal
public class EqTest{
public static void main(
String argv[]){
EqTest e=new EqTest();
}
EqTest(){
String s="Java";
String s2="java";
//place test here {
System.out.println("Equal");
}else
{
System.out.println("Not equal");
}
}
}
1) if(s==s2)
2) if(s.equals(s2)
3) if(s.equalsIgnoreCase(s2))
4)if(s.noCaseMatch(s2))
If i use if(s==s2) i get o/p as Not Equal
my query is, == operator checks the memory reference so the
o/p should be Equals.
Does it mean that it also checks the value in strings
or is there any other explanation.
Thanks in advance