一道JAVA 考试题 请高手指点
在amay的scjp试题中有这样一道题目:
Click the exhibit button:
1. public class test {
2. public static void stringReplace (String text) {
3. text = text.replace (‘j’ , ‘i’);
4. }
5.
6. public static void bufferReplace (StringBuffer text) {
7. text = text.append (“C”)
8. }
9.
10. public static void main (String args[]) {
11. String textString = new String (“java”);
12. StringBuffer textBuffer = new StringBuffer (“java”);
13.
14. stringReplace (textString);
15. bufferReplace (textBuffer);
16.
17. System.out.println (textString + textBuffer);
18. }
19. }
What is the output
答案是javajavaC,我不清楚为什么textString的内容没有改变而textBuffer的内容改变了,我是菜鸟弄不明白阿
请高手指点谢谢了