Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add Map values into an arraylist in java?  RSS feed

 
Anup Borde
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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}]
 
Piet Souris
Rancher
Posts: 1980
67
  • Mark post as helpful
  • send pies
  • 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.
 
Jason Bullers
Ranch Hand
Posts: 115
11
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!