I am just a beginner and learning Java to my own! I just have an arraylist of objects of Users:
class Users{
public userName;
public userNumber;
}
then I create a model as:
ArrayList<Users> model=new ArrayList<Users>();
and added the model items as:
model.add(new Users("abc","123"));
model.add(new Users("def","888"));
model.add(new Users("abc","246"));
model.add(new Users("def","999"));
model.add(new Users("abc","456"));
What I want to do is to print the model in this way that should show similar grouped data with group name as:
for(int i=0;i:i<users.size;i++){
System.out.printlin("users:::"+users.get(i).userNumber);
}
But it should group and print group by name too that is:
abc ->
users:::123
users:::246
users:::456
def ->
users:::888
users:::999
So I want to group the data and then print the data in grouped format with each group name also!
How can I do that, I am just learning Java to my own. Thanks in advance