arraylist - Casting list of objects to list of maps in java -
this question has answer here:
- java: how convert list map 13 answers
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
Post a Comment