Copy a string: Difference between revisions

Content added Content deleted
(Warning about comparing strings)
(→‎[[Java]]: Changed example so it shows aliasing and fixed a typo in it.)
Line 134: Line 134:
[[Category:Java]]
[[Category:Java]]
String src = "Hello";
String src = "Hello";
String dst = new String(s);
String newAlias = src;
String strCopy = new String(src);
//"newAlias == src" is true
//"strCopy == src" is false
//"strCopy.equals(src)" is true


==[[JavaScript]]==
==[[JavaScript]]==