4-String字符串

1-String对象的内容比较

public class StringDemo01 {
    public static void main(String[] args) {
        String str1 = "hello";
        String str2 = new String("hello"); //通过new赋值
        String str3 = str2; //传递引用对象

        //输出结果
        System.out.println("str1 == str2-->"+(str1 == str2)); //flase
        System.out.println("str1 == str3 -->"+(str1 == str3)); //flase
        System.out.println("str2 == str3-->"+(str3 == str2)); //true
    }
}

1-1内存图说明

4-String字符串

上一篇:c++ insert


下一篇:day1python基础