- public class Demo {
- public static void main(String[] args) {
- String s1 = "hello";
- String s2 = "world";
- String s5 = s1 + s2;
- String s3 = "hello" + "world";
- String s4 = "helloworld";
- String s6 = s4.substring(0,5);
- System.out.println(s3 == s4);
- System.out.println(s3.equals(s4));
- System.out.println(s3 == s5);
- System.out.println(s3.equals(s5));
- System.out.println(s1 == s6);
- System.out.println(s1.equals(s6));
- }
- }
复制代码
写出结果,并分析原因. |
|