关于String 类

package com.shan.thinkinginjava.finalize;


public class Node {
public static void main(String[] args) {
String[] name = new String[]{"shan","dan"};
String  name0= "shan";
String  name1= "dan";
swap(name);
System.out.println(name[0]+ ",,."+name[1]);
swap(name0, name1);
System.out.println(name0+",,,,,,,,,,,,,,"+name1);

}
public static void swap(String[] name){
String temp = null;
temp = name[0];
name[0] =name[1];
name[1] = temp;
}

public static void swap(String name0,String name1){
String temp = null;
temp =name0;
name0= name1;
name1 = temp;
}

}


输出

dan,,.shan
shan,,,,,,,,,,,,,,dan


String类是final的、

你可能感兴趣的:(关于String 类)