问答详情
源自:6-8 使用 foreach 操作数组

foreach的疑惑, 求大神解答,,,,,,,,

如果定义的数组为  int score[];怎么用foreach呢?中间的  元素变量是代表什么?                    

提问者:丶所剩无几 2017-04-08 19:58

个回答

  • 慕粉1833584446
    2017-04-08 20:15:46
    已采纳

    这样写  for(int i:score){

    }

    中间代表元素 i  表示的是 score[ index];

  • 慕粉1219432052
    2017-04-08 20:17:21

    for(int s:score){ System.out.println(s);

    }

    这样可以输出数组