当前位置: 代码迷 >> Java相关 >> 急求for的双循环写法
  详细解决方案

急求for的双循环写法

热度:73   发布时间:2008-06-17 23:19:38.0
急求for的双循环写法
在线急求for的双循环写法
搜索更多相关的解决方案: 双循环写法  在线  

----------------解决方案--------------------------------------------------------
你的双循环,是不是内外欠套?如果是的,那么很简单的。

代码如下:

for( ; ; )
//your code
for( ; ; )
   //your code
----------------解决方案--------------------------------------------------------
这里一段演示性代码:
程序代码:

public class TwoleverForloop
{
  public static void main(String [] args)
  {
    //2d array alocation, just demo
    int twoDarray[][] = new int[3][3];
    
    //2d array init, just demo
    for(int i = 0; i<3; i++)
    {
      for(int j = 0; j<3; j++)
      {
        twoDarray[i][j] = (i+1)*(j+1);
      }
    }
    
    //display
    for(int i = 0; i<3; i++)
    {
      for(int j = 0; j<3; j++)
      {
        System.out.print(twoDarray[i][j]);
      }
      //make a new line
      System.out.println();
    }
  }
}

----------------解决方案--------------------------------------------------------
for(;;){
for(;;){
}
}

第一个大括号和最后一个对应
----------------解决方案--------------------------------------------------------
  相关解决方案