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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -