大家好,首先看一下下面這段代碼:
ublic class fillTheGaps {
int foo(String x, int number, int[] array){
number = array.length;
x = x + "xAtfoo";
for (int i=0; i < number; i++){
array[i] = array[i] + x.length();
}
x = x + "Success";
return x.length();
}
void bar(){
String s = new String("Hello");
int num = 6;
int [] array = {1, 2, 3, 4};
int result = 0;
result = foo(s, num, array);
}
public static void main (String[] args){
fillTheGaps ftp=new fillTheGaps();
ftp.bar();
System.out.println();
}
}
假設,我們調用方法bar(),填寫執行方法result=foo(s,num,array)之前和之後的變量的值。
Before: 1 2 3 4
After: Hello 6 12 13 14 15 18