Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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;
Posted
Updated 23-Apr-12 20:31pm
v2

1 solution

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".
 
Share this answer
 
Comments
mpvkrishnadhar 24-Apr-12 2:30am    
u r right buddy! but what about the first error message!
mpvkrishnadhar 24-Apr-12 2:31am    
oops buddy the question was for 1 error message! typo mistake!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900