jagged array error message
-
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;
-
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;
Hi, You have the answer. It is what you have said. We need to specify the array size. Regards, Satish Pai
-
Hi, You have the answer. It is what you have said. We need to specify the array size. Regards, Satish Pai
oops! that was a typo mistake! i was asking about the first error message!
-
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;
int [][]j1=new int[][];
You are asking the system to create an array, but you have not told it how big the array should be.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
-
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;
The problem is that you are defining j1 as "an array of [arrays of ints]". So when you try to create a new instance of it, you have to tell it how many "arrays of ints" this instance will be. If you defined
int[] arr = new int[];
then it is clearly wrong: it acan't allocate space for an unknown number of objectes, you have to say
int[] arr = new int[7];
So enter a size for the array:
int[][] j1 = new int[100][];
And all will be well.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
The problem is that you are defining j1 as "an array of [arrays of ints]". So when you try to create a new instance of it, you have to tell it how many "arrays of ints" this instance will be. If you defined
int[] arr = new int[];
then it is clearly wrong: it acan't allocate space for an unknown number of objectes, you have to say
int[] arr = new int[7];
So enter a size for the array:
int[][] j1 = new int[100][];
And all will be well.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
oooh! now i get it!
-
oooh! now i get it!
I love those "lightbulb" moments! :laugh:
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water