2 faradayzhangchina FaradayZhangChina 于 2015.05.28 12:53 提问

执行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)之前和之后的变量的值。
图片说明

2个回答

llx1943llx
llx1943llx   2015.05.28 13:01
已采纳

Before: 1 2 3 4
After: Hello 6 12 13 14 15 18

gamefinity
gamefinity   Rxr 2015.05.28 12:58

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

Csdn user default icon
上传中...
上传图片
插入图片