package test;
public class Main {
public static void main(String[] args) {
String s1 = "WTY2002"; //s1 指向池中的 “WTY2002”
String s2 = "java"; // s2 指向池中的 “java”
String s5 = "WTY2002java"; //s5 指向池中的 “WTY2002java”
String s6 = (s1 + s2).intern();//s6 指向池中的 “WTY2002java”
System.out.println(s5 == s6); //T
System.out.println(s5.equals(s6));//T
}
}
package test;
public class Main {
public static void main(String[] args) {
}
}
class Test1 {
String str = new String("hsp");
final char[] ch = {'j', 'a', 'v', 'a'};
public void change(String str, char ch[]) {
str = "java";
ch[0] = 'h';
}
public static void main(String[] args) {
Test1 ex = new Test1();
ex.change(ex.str, ex.ch);
System.out.print(ex.str + " and ");
System.out.println(ex.ch);
}
}