在c#中有
int[] i={3,45,6}
foreach(int j in i)
{
  //输出
}
在java中有没有foreach,怎么写?

解决方案 »

  1.   

    public class Test{
      public static void main(String args[]){
        int[]  i={3,45,6};
        for(int j=0;j<i.length;j++){
          System.out.println(i[j]);
        }
      }}
      

  2.   

    int[] i = {3,45,6}
    for(int j : i )
    System.out.println(j)
      

  3.   

    for我知道我想知道像foreach这样怎么写,不过谢谢你。
      

  4.   

    那看看这个吧,我也刚找的。
    http://www.moon-soft.com/doc/51642.htm
      

  5.   

    有jdk1.5的新方法 ,可以查一下比较新的书 ,会找到
      

  6.   

    int[]   i={3,45,6};for(int   j  : i)  // 用这个格式的for语法就可以 

        //输出 
    } 再比如
    List<Person> list = ...
    for(Person p : list) {
      p. 
    }