+ 4
Why String str="hello" and String str = new String("hello") are different?
when we compare both by comparison operator it will give false as result
4 Answers
+ 8
Looks like Java.
basically new string just creates a new value on a heap. comparison checks for reference equality, so it will return false for that code.
Actually even if you don't use new to allocate a memory it still might do it by itself (depending on some things)
0
yes,the new string is the object string while, the other one is normal string js
- 2
hello is a string which assign to str and string str= new str("hello") is assing to constracture value
- 3
mujhe seekhni hai c lenguage sir