当前位置: 代码迷 >> J2SE >> 怎么定义和C类似的变量
  详细解决方案

怎么定义和C类似的变量

热度:271   发布时间:2016-04-24 15:13:45.0
如何定义和C类似的变量
import   java.util.Scanner;
public   class   Juzheng1
{   public   static   void   main(String   args[])
      {   int   a[][]=new   int[3][4];
          int   b[][]=new   int[4][3];
          int   i,j;
          System.out.println( "a: ");
        for(i=0;i <3;i++)
              {   for(j=0;j <4;j++)
                  a[i][j]=input.nextInt();
                  System.out.println();
              }
。。。。。。。。。。。
如何定义象C语言中的
#define   row     9
#define   col     8
而不是预先分配好3行4列。。。如何随心所欲输入?
谢谢!



------解决方案--------------------
int row = 8;
int col = 9;
int a[][]=new int[row][col];
int b[][]=new int[col][row];
  相关解决方案