Topic: 二唯数组的下标不可以是变量吗!! |
Print this page |
1.二唯数组的下标不可以是变量吗!! | Copy to clipboard |
Posted by: 234aini Posted on: 2004-11-06 12:25 class toString //为什么二唯数组的下标不可以是变量恩? 一运行就报错 |
2.Re:二唯数组的下标不可以是变量吗!! [Re: 234aini] | Copy to clipboard |
Posted by: littledeer1974 Posted on: 2004-11-06 12:44 1.二维数组(Array)的下标可以是变量(使用时) 2.但是在生成的(new)时候,下标不可以是变量 3.如果你想动态(并非真正的动态,真正的动态生成存储空间的请您参照其他算法)的决定数组大小,可以 int[][] yourArray; |
3.Re:二唯数组的下标不可以是变量吗!! [Re: 234aini] | Copy to clipboard |
Posted by: boynick_1 Posted on: 2004-11-07 17:49 我试了一下,好象也不行啊 class test { public static void main(String args[]) { int[][] ary; int x; int y; x=x+1; y=7; ary=new int[x][y]; } } 报错: E:\java\test.java:9: variable x might not have been initialized x=x+1; ^ 1 error |
4.Re:二唯数组的下标不可以是变量吗!! [Re: boynick_1] | Copy to clipboard |
Posted by: littledeer1974 Posted on: 2004-11-07 17:52 you need to initialize your x not just x=x+1; x was null,so x=x+1 means x=null+1(still null) you can try this x=6; x=x+1; |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |