定义没有声明呀
int[] x; 定义
x=new int[10]; 初始化
int[] x; 定义
x=new int[10]; 初始化
解决方案 »
- 字符串高亮问题,在Swing程序中 ,用哪个组件方便?
- 判断两个对象是否相等重写hashcode()的问题
- System.out.write()输出不显示问题!
- [请教]我的JNI库调用,package包找不到路径
- java被淘汰了?
- 初学者问个简单问题,关于调用自编写类的问题
- Servlet action is not available
- 加急快信~~~~~~~~~~数组问题,望高手指点!~~
- 求助高手!!
- J2SDK 1.4.1 版安装后测试出现问题请高手帮忙!
- swing的问题:用paint() 方法被重复调用。。
- html:option 标签中的value值,如何从资源文件中读取数据?超着急......在线等待!!!!!!
int[] a1;
or int a1[];
All that you have at this point is a reference to an aray,and there's been no space allocated for the array.
To create storage for the array ,you must write an initialization expression.
而int s[]=new s[10]是正确的!
System.out.println("The array length is "+x.length);
用上面语句可以打印出长度
但如何打印出二维数组的长度呢
比如下面的语句
int xx[][]=new int [3][2];
System.out.println(xx.length); \\这句输出3
我相让他输出2有这个可能吗?
如果可以的话该如何写?
可以看成如下2步
int[] x; 定义
x=new int[10]; 初始化
换本书吧.....
在它初始化的时候就能指定了 x=new int [20];