Java笔试题-string、char[]

package dataTransfer;

public class Demo {

    String str = new String("good");

    char[] chs = new char[] { 'a', 'b', 'c' };

    public void change(String str, char[] chs) {

        // str = "test ok";

        str = new String("good");

        chs[0] = 'g';

        System.out.println(this.str.intern() == str.intern());

        System.out.println(this.str == str);

        System.out.println(this.chs == chs);

    }

    public static void main(String[] args) {

        Demo demo = new Demo();

        demo.change(demo.str, demo.chs);

        System.out.println(demo.str + "---");

        System.out.println(demo.chs);

    }

}

你可能感兴趣的:(Java笔试题-string、char[])