標題:
方法中傳值呼叫與傳參考呼叫
[打印本頁]
作者:
buy
時間:
2010-10-24 19:33
標題:
方法中傳值呼叫與傳參考呼叫
import java.io.*;//for 鍵盤輸入
import java.lang.Math;
import java.util.ArrayList;
public class Hello
{
public static void main(String args[])throws IOException
{
int a = 99;
int b[] = new int[]{99};
String s = "99";
add99(a,b,s);
System.out.println(a + "," + b[0] + "," + s);
}
public static void add99(int a,int [] b,String s)
{
a = a+1;
b[0] = b[0]+1;
s = s + "1";
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2