As the java-doc tells Java Operator ==
tests for reference equality (whether they are the same object). so "==" operator will return true only if two object reference it is comparing represent exactly same object otherwise "=="
will return false.
But while running a piece of code all i found is that this statement doesn't satisfy the Output of the code. Here's the code:
public class Test2 {
public static void main(String[] args)
{
String s="Sachin";
String t="Sachin";
System.out.println(s==t);
}
}
And Surprisingly i found a output "true"
.
Please Help me understand why it is so?
Here's a Screenshot to my program output: