arraylist - Casting list of objects to list of maps in java -


this question has answer here:

i'm having list of objects this.

[     [     "abhay pawde",     "development"     ],     [     "dinesh",     null     ] ] 

i want convert them list of maps example mentioned below:

[     [     "name":"abhay pawde",     "dept":"development"     ],     [     "name":"dinesh",     "dept":null     ] ] 

how achieve in java ? i'm not sure if there other solution mentioned here. please let me know. list of objects obtained after querying database.

you could collect map using jdk-8 features, like:

 yourlist.stream()         .map(collectors.tomap(yourobject::getname, yourobject::getdepartment)) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -