| 
| 下面是String文档的说明,而==比较的是引用,equals比较的才是内容 
 Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
 
 String str = "abc";
 
 
 is equivalent to:
 
 char data[] = {'a', 'b', 'c'};
 String str = new String(data);
 复制代码/*异常*/
class  StringDemo
{
        public static void main(String[] args) 
        {
                byte []ch = {'a','b','c'};
                String s1 = "abc";
                String s2 = new String(ch);
                String s3 = "abc";
               System.out.println(s1==s2);
                           System.out.println(s1==s3);
                                System.out.println(s1.equals(s2));
            
        }
}
 | 
 |