探索String加法运算符(Java版本)
发布时间
阅读量:
阅读量
JDK1.8实验环境配置
IDEA2021实验环境配置
最近做了一些关于String的面试题引发了一些思考,代码如下
public static void main(String[] args) {
String s1 = "hello";
String s2 = "world";
System.out.println("hello" + "world" == "helloworld");
System.out.println("-----------");
System.out.println(s1 + s2 == "helloworld");
System.out.println("-----------");
System.out.println("hello" + s2 == "helloworld");
}
结果如下:
true
-----------
false
-----------
false
全部评论 (0)
还没有任何评论哟~
