I would like to see an example where a String object, st String st = new String("wow") loses its object reference, when a method modifyIt(st), that takes a string object, is able to change the contents of the object by supplying something like "oops". This should get returned and displayed in the main method, when a call to println is made. "oops"
Harpal Singh
Ranch Hand
Joined: Oct 10, 2000
Posts: 229
posted
0
Dear sarim, Strings are immutable....hence cannot be changed..but can be made to point to new object of there type...Hope the below code helps.... <pre> class sarim { static String st = new String("wow"); public static void main(String[ ] args) {