+ 2
String immutable class
where is the initialized obj of String s="hello"; Class A{ public static void main(String[] args){ String s="hello"; s=s.concat(" world"); System.out.pruntln(s); } Above this prgmm ' s ' is a immutable class ,then i will assign value . The output is hello world . Its create a new obj . So where is the initialized obj . its gone or replace ? who can pointing to "hello"?
1 Answer
0
It's in the stack, so after the scope it doesn't exist.