Monday 22 January 2018

What is the difference between String str1 = "hello"; and String str2 = new String ("hello"); in java?

What is the difference between String str1 =
"hello";
and String str2 = new String ("hello");
in java?



I know the
str2 is a object, but what about
str1?




I mean
for example:



if both of them are object, but why



if(str1.toString() ==
str2.toString())


does
not result a true boolean?

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...