argument可以是"值"或"變數"
argument可以是"值"或"變數"
e.g. 當作值傳入:
void go() {
TestStuff t = new TestStuff();
t.takeTwo(3, 7);
}
void takeTwo(int x, int y) {
int z = x + y;
System.out.println("Total is " + z); // Total is 10
}
e.g. 當作變數傳入:
void go() {
TestStuff t = new TestStuff();
int foo = 7;
int bar = 3;
t.takeTwo(foo, bar);
}
void takeTwo(int x, int y) {
int z = x + y;
System.out.println("Total is " + z); // Total is 10
}
e.g. 當作值傳入:
void go() {
TestStuff t = new TestStuff();
t.takeTwo(3, 7);
}
void takeTwo(int x, int y) {
int z = x + y;
System.out.println("Total is " + z); // Total is 10
}
e.g. 當作變數傳入:
void go() {
TestStuff t = new TestStuff();
int foo = 7;
int bar = 3;
t.takeTwo(foo, bar);
}
void takeTwo(int x, int y) {
int z = x + y;
System.out.println("Total is " + z); // Total is 10
}
留言
張貼留言