黑马程序员技术交流社区

标题: 看程序求结果 [打印本页]

作者: liuzegang    时间: 2016-2-6 18:24
标题: 看程序求结果
public class Demo {
        public static void main(String[] args) {
                String s1 = "hello";
                String s2 = "world";
                System.out.println(s1 + "---" + s2);
                change(s1, s2);
                System.out.println(s1 + "---" + s2);
        }
        public static void change(String s1, String s2) {
                s1 = s2;
                s2 = s1 + s2;
        }
}


作者: tujiu888    时间: 2016-2-7 10:29
都是 hello---world
作者: davy0119    时间: 2016-2-7 17:32
hello---world
作者: renkuo023    时间: 2016-2-7 21:06
hello---woeld
作者: renkuo023    时间: 2016-2-7 21:08
hello---world
作者: liuzegang    时间: 2016-2-8 15:40
终于搞懂了,String是常量
作者: 酱油    时间: 2016-2-9 21:18
hello--world
hello--world
基本数据类型,都是按值传递,,,
作者: 1178988315    时间: 2016-2-9 23:09
hello---world
作者: shiax11    时间: 2016-2-10 07:57
hello ———— world
作者: 晓寒轻    时间: 2016-2-10 19:59
看来 都知道啊。。。hello---world
作者: Android666    时间: 2016-2-10 21:59
hello--world




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2