Hi,
going thru a practice
test I came across the following question and don't understand it:
Public class test(
Public static void stringReplace(
String test)(
test = test.replace ("j", �");
)
public static void bufferReplace (StringBuffer test)(
test = test.append("C");
)
public static void main(String args[]) (
string testString = new String ("java");
StringBuffer text BufferString = new StringBuffer ("java");
stringReplace (testString);
BufferReplace(testBuffer);
System.out.println(textString + textBuffer);
)
)
The answer is javajava.
To me should be iavajavaC
Why? because String is an object not a type, and
java passes ref to the
called function. The called function can manipulate the original object
thru the ref.
Thanks,
Robert