How to save key value pair of different data type in java

Viewed 37

How to save key value pair of different data type in java

I have list of data here

[
{name:”david”, roll : 101, id: 101-david, dept: “cs”, type:”admin”, someExtra : “etc”},
{name:”david”, roll : 102, id: 102-david, dept: “ECE”, type:”admin”, someExtra : “etc”},
]

Which is coming from this

public MyModel(String name, String roll, UUID id,  Dept dept, String admin, String someExtra, Geometry myModel) {
    this.name = name;
    this.roll= roll;
    this.id = id;
    this.dept = dept;
    this.admin = admin;
    this. someExtra = someExtra;
    this. myModel = myModel
}

So as you can see I have different types like Dept.

I want to this Result :

[
    {name:”david”, roll : 101, id: 101-david, dept: “cs”},
    {name:”david”, roll : 102, id: 102-david, dept: “ECE”},
]

Problem which I am having is How to make this result through any of the Java Collection.

0 Answers
Related