执行result=foo(s,num,array)前后的变量的值

大家好,首先看一下下面这段代码:

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

调用之前,"Hello",6,1,2,3,4,0
调用之后,"HelloxAtfooSuccess",6,12,13,14,15,18