I have some questions about this
thread.
String is immutable as I know, s will not change only if we assign a new value. In line 1, s still "ball", right? But in line 2, s copy its reference to str, and pass it ref to modify method, str is point to "base" also. In line 3, "baseball" will assign to the str reference, str and s reference are the same which point the obj, why output the s value is "base"? Is it the reason of the String is immutalbe?
If use StringBuffer instead of String, the result is output "baseball". Or just handle String object with primitive policy? I fill confuse at this situation with String object, anyone would give me some ideas? thx in advance.
[ November 14, 2002: Message edited by: Kelvin Michael ]