This week's book giveaway is in the Other Languages forum. We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line! See this thread for details.
Could anyone explain why this code from Dan Chisholm mock exam have the output of "ABABCABC"?
When s1 was passed to m1, shouldn't another copy of s1 be created and changed which does not affect s1 itself?
posted 12 years ago
Serena, Java does always pass by value, making a copy and then passing it. But also remember that in Java, references to Java is what is being copied. So, the reference is copied and pass. The copy still refers to the same StringBuffer though, so both m1 and m2 alter the same StringBuffer.