File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to print the elements of an arraylist that contains a hashmap

 
Ayan Biswas
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have ArrayList<HashMap>.the HashMap stores(String,Integer) as (key ,value) pair.how will I display all the elements of the arraylist.
 
Claudiu Chelemen
Ranch Hand
Posts: 75
Eclipse IDE Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ayan.

If you simply use a System.out.println() on the list, it displays quite nice.
In case you need some kind of formatted output, please detail.

Cheers,
Claudiu
 
Harsha Smith
Ranch Hand
Posts: 287
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ayan Biswas
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sorry,for not being precise with my query.
Actually,I need to access each (KEY,VALUE) pair from each hashmap and then do some updation on the elements of each hashmap and then display it.
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ayan Biswas wrote:
Sorry,for not being precise with my query.
Actually,I need to access each (KEY,VALUE) pair from each hashmap and then do some updation on the elements of each hashmap and then display it.


You would have to iterate through the list- you can use Enhanced for loop. so you get HashMap instances on each iteration, use it to get the key-value pairs.
So if you can convert this into code, we would be able to help you further
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic