欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java String你知道少 博客分类: java 语言 java String

程序员文章站 2024-03-02 10:55:22
...

请看下面代码,然后写出输出结果

 

package testPackage; 

class Test { 

    public static void main(String[] args) { 

        String hello = "Hello", lo = "lo"; 

        System.out.print((hello == "Hello") + " "); 

        System.out.print((Other.hello == hello) + " "); 

        System.out.print((other.Other.hello == hello) + " "); 

        System.out.print((hello == ("Hel"+"lo")) + " "); 

        System.out.print((hello == ("Hel"+lo)) + " "); 

        System.out.println(hello == ("Hel"+lo).intern()); 

    } 

class Other { static String hello = "Hello"; }

 

 

//另外一个package

package other; 

public class Other { public static String hello = "Hello"; }

 

大家来试试吧

相关标签: java String