I am trying to write the following code…
static ArrayList<RssItem>[][] list = new ArrayList<RssItem>[][];
This doesn’t work. What am I doing wrong, if I am trying to create a list of ArrayList<RssItem>?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to give the size on the RHS: –
Size of
columnis not needed, but you can give it too: –NOTE: –
You cannot give a
specifictype as a type parameter on theRHS. You would have to useWildCard. Specific type would only be given when you are instantiating yourlistin the array.To add something to your array, you can use this kind of loop: –
NOT Tested
P.S.: –
Please don’t use 2-D array of
List. That is equivalent to a 3-D array. Even if you get the above loop to work somehow. It will make your code mess in future. And your life hell. There are many other data structures in Java, that you should consider, like aMap, which is useful in such kind of situations.Even, having a
Listupto 3 levels is a very bad idea. So, please change your design.