锯齿状数组的错误消息 [英] error message of jagged array

查看:79
本文介绍了锯齿状数组的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


今天学会了锯齿状阵列并正在与他们合作!遇到两条错误消息

int [] [] j1 = new int [] [];

现在我收到两个显示的错误消息

1)当我将光标/指针放在新的int部分上时,我会看到以下错误消息

"[[]内的索引数量错误; excepted1"

2)当我将光标保持在索引上时,将显示以下错误消息

数组创建必须具有数组大小或数组初始化程序".

第2条错误消息非常简单明了,因为它解释了在JAGGED ARRAYS情况下需要声明数组(行)大小或初始化(行)数组的必要性

我的问题在这里是第一个错误消息的含义;

解决方案

锯齿状数组包含数组的集合.当你说
int [] [] j1 = new int [] [];在这里,您没有指定j1中应该有多少个数组.因此,编译器给出了错误消息数组创建必须具有数组大小".


hi
learned jagged array today and was working with them! came across two error messages

int [][]j1=new int[][];

now i get two error messages displayed

1) when i keep my cursor/pointer on the new int part then i get to see the following error message

"Wrong number of indices inside[];excepted1"

2) when i keep my cursor/pointer on the indices then the following error message is displayed

"Array creation must have array size or array "initializer".

2nd error message is pretty straight forward as it explains about the need to declare an array(row) size or initialize the(row)array in case of JAGGED ARRAYS

my question here is what is the meaning of the first error message;

解决方案

Jagged array contains collection of arrays. When you say
int [][]j1=new int[][]; here you are not specifying how many arrays should be there in j1. So compiler is giving error message "Array creation must have array size".


这篇关于锯齿状数组的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆