黑马程序员技术交流社区

标题: 学习笔记 [打印本页]

作者: 胡俊焰    时间: 2015-7-18 00:06
标题: 学习笔记
String类(掌握)
        (1)字符串:多个字符组成的一串数据。
        (2)构造方法:
                A:String s = new String();
                B:String s = new String(byte[] bys);
                C:String s = new String(byte[] bys,int index,int length);
                D:String s = new String(char[] chs);
                E:String s = new String(char[] chs,int index,int length);
                F:String s = new String(String str);
                G:String s = "hello";
        (3)字符串的特点及面试题
                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));
作者: 鲤鱼仙    时间: 2015-7-18 00:09
心动的一天加油~~! 为了目标加油~




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