面向对象String

来源:互联网 发布:上海微创软件无锡 编辑:程序博客网 时间:2024/05/16 11:55

面向对象String

1、“==”内容比较

public class ZiFuChuan
{
    public static void main(String[] args)
    {
        String str1="hello world";
        String str2="hello world";
        String str3="hello world";
        System.out.println("str1==str2-->"+(str1==str2));
        System.out.println("str1==str3-->"+(str1==str3));
        System.out.println("str2==str3-->"+(str2==str3));
    }
}

结果

2、String类中,字符串内容一旦声明则不可改变,其变化是“改变的是对内存地址的指向”

0 0
原创粉丝点击