Thursday, September 5, 2019

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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...