hi ,
I have a question on immutability from chapter 2 from
OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808
. The example :
line 1 String s1 = "1";
line 2 String s2 = s1.concat("2");
line 3 s2.concat("3");
line 4 System.out.println(s2);
prints 12
but if instead if line 3 is s2 = s2.concat("3") . the result would be 123 . how does it make difference ? A bit confused on this .
Thanks ,
Liza