• 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

2D ArrayList and converting to HashMap

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one help me in coding a 2D ArrayList and convert it into HashMap.?
Thanks in Advance
 
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

Saikrishna Vemuri wrote:Can any one help me in coding a 2D ArrayList and convert it into HashMap.?
Thanks in Advance


Before Campbell starts ranting, I'll set you straight: There is no such thing as a 2D ArrayList.

What you can have is an ArrayList of ArrayLists, which is almost the same thing; and the definition for it would look something like:
List<List<SomeClass>> my2DList = new ArrayList<ArrayList<SomeClass>>();

But how you convert it to a HashMap will depend entirely on how you want to do it; and for that we'll need a lot more information.

Winston
 
Saikrishna Vemuri
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my concern is adding items to the list .
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Saikrishna Vemuri wrote:my concern is adding items to the list .


Then you should check this first and then come back with more specific problem.
 
Winston Gutkowski
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

Saikrishna Vemuri wrote:my concern is adding items to the list .


OK, well firstly, you're going to need to add them in order (or at least it's going to be an awful lot easier), because an ArrayList is NOT an array. To be honest, if this structure is meant to simulate a matrix, I'd suggest that you use a Map rather than a "2D" ArrayList; otherwise just use a plain old 2D array (sorry Campbell), viz:
SomeClass[][] = new SomeClass[10][10];

I think perhaps you need to explain a bit more about what you want to do.

Winston
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote: . . . Before Campbell starts ranting, . . .

That’s 2D arrays I go on about
But you are right; there ain’t no such thing as a 2D ArrayList either.
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:. . . 2D array (sorry Campbell) . . .

I bet you aren’t sorry at all; you are only saying that to wind me up
 
reply
    Bookmark Topic Watch Topic
  • New Topic