• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to create two dimensinal array list?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.??
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
See where your hand is? Not there. It's next to this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic