阅读背景:

String类型作为方法的形参

来源:互联网 

代码:

public class TestString {
	
	String str = new String("good");
	char [] ch = {'a','b','c'};


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		TestString ex = new TestString();
		 ex.change(ex.str,ex.ch);
		System.out.println(ex.str+"and");
		System.out.println(ex.ch);

	}
	
	public  void change(String str2, char[] ch2) {
		System.out.println("交换前:" + str2);
		//result is the same
		//str2 = new String("test ok");		 
		str2 = "test ok";
		System.out.println("交换后:" + str2);
		ch[0] = 'g';
		
	}


}
public class TestString {
	
	String s



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: