A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© zhaoqiankun 中级黑马   /  2015-4-9 22:21  /  325 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

A:字符串一旦被赋值,就不能改变。
                        注意:字符串的值不能改变,没有说引用变量不能改变。
B:面试题:
                        a:String s = new String("hello")和String s = "hello"的区别。
                        b:请写出结果:
                                String s1 = new String("hello");
                                String s2 = new String("hello");
                                System.out.println(s1==s2);
                                System.out.println(s1.equals(s2));

                                String s3 = new String("hello");
                                String s4 = "hello";
                                System.out.println(s3==s4);
                                System.out.println(s3.equals(s4));

                                String s5 = "hello";
                                String s6 = "hello";
                                System.out.println(s5==s6);
                                System.out.println(s5.equals(s6))

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马