Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to add Map values into an arraylist in java?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is the current output that i get


[{rate=24000,weight=21.000,desc=item description,makingAmt=200,cstName=Test customer,sum_total=52094.46,vat=1021.46,itemTotal=51073,barcode=BQSP78BB,net_rate=24200,invoiceNo=1842,bill_type=estimate,contact=+91-8600931386}]



What I am trying to do is add a map to an arraylist.My expected output is as follows:


[{rate=24000,weight=21.000,desc=item description,makingAmt=200,cstName=Test customer,sum_total=52094.46,vat=1021.46,itemTotal=51073,barcode=BQSP78BB,net_rate=24200,invoiceNo=1842,bill_type=estimate,contact=+91-8600931386},{rate=24000,weight=21.000,desc=item description,makingAmt=200,cstName=Test customer,sum_total=52094.46,vat=1021.46,itemTotal=51073,barcode=BQSP79BB,net_rate=24200,invoiceNo=1842,bill_type=estimate,contact=+91-8600931386},
{rate=24000,weight=21.000,desc=item description,makingAmt=200,cstName=Test customer,sum_total=52094.46,vat=1021.46,itemTotal=51073,barcode=BQSP80BB,net_rate=24200,invoiceNo=1842,bill_type=estimate,contact=+91-8600931386}]

 
Bartender
Posts: 5077
189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anup,

well, just repeat line 19 twice.

But what are you trying to achieve?

Edit: missed it on my small tablet, but you are using
the add(index, item) method. So, repeat also line 20.
 
Ranch Hand
Posts: 115
11
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your first output already shows the map added to the list. But in your expected output, you show the same map added to the list three times. To understand your problem a little better I would ask: why do you want the same map added to the list three times?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic