String s3= new String("lkj"); String s4= new String("lkj");
here how many objects are created?i am confused a bit when string r created using new.since s3 and s4 have the same value are there 2 objects areated or s4 also points ot s3. thanks
Above code will create 2 objects 1- String "jkl" which will be placed in String pool. 2- String object pointed by s3 which contain string "jkl" from string pool.
Here String object "jkl" will be reused from pool and object for s4 will be created
So there would be total 3 objects
"Know where to find the solution and how to use it - that's the secret of success."