Group by field name in Java

前端 未结 7 1819
迷失自我
迷失自我 2020-12-01 05:35

I\'m trying to group Java objects by their field, i.e Person.java

public class Person {
    String name;
    String surname;
    ....
}
相关标签:
7条回答
  • 2020-12-01 06:30

    First of all you should add objects of Person.java in the arraylist later we can get back those details in below manner

    public void addPerson(){

    ArrayList presonList = new ArrayList();

    for( int i=0;i<=presonList.size() ; i++){

    Person obj = presonList.get(i);

    //now do the stuff of getting individual variable here

    }

    }

    0 讨论(0)
提交回复
热议问题