• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to create two dimensinal array list?  RSS feed

 
richard parkers
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i was trying to read arff file using weka api and it executes well. the i reference variable holds the data.

My question is can I use an arraylist to hold the data from i. how can it be done.??
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
richard parkers wrote:My question is can I use an arraylist to hold the data from i. how can it be done.??

Well, there's no such thing as a 2-dimensional ArrayList in Java; just as there's no such thing as a 2-dimensional array.

What there is, however, is an ArrayList of ArrayLists - ie, a:
ArrayList<ArrayList<Whatever>>

How do you think that might help?

Winston
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about: ArrayList[][] arlist = new ArrayList[3][4]? Can't get it any more two dimensional than that!

Note that this is not generic, though.

Greetz,
Piet
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Richard!

I can't understand why you would want to put the data from a perfectly good object into the elements of a List. From the class name ("Instances") it looks like it's supposed to be holding a set of things already -- so doesn't it have methods for getting those things out? I wouldn't get them out and put them back into an ArrayList unless there was a really good reason to do so.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!