Tuesday 31 October 2017

Why the final keyword can make strings equal in java

public class Test
{

public static void main(String[] args) {
String a =
"hello2";
final String b = "hello";
String d =
"hello";
String c = b + 2;
String e = d + 2;

System.out.println((a == c));
System.out.println((a ==
e));
}



The
result is True and False.
Does "==" not mean that the string address is
equal?
I think the result is False Fasle

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...