You could have an arraylist for every group that holds the names of every player in that group. Then you could easily get the names of people in the group and the number of people in it. so if you have a class named Group you could have something like:
class Group {
private ArrayList<String> users; // or instead of String if you have a User class use that
public Group(Type par) {
users = new ArrayList<String>();
}
public static void addUser(String userName) {
users.add(userName);
updateUsers();
}
public static void removeUser(String userName) {
for(int i = 0; i < users.size(); i++) {
if(users.get(i).equalsIgnoreCase(userName)) {
users.remove(i);
}
}
updateUsers();
}
public static int getNumberOfUsers() {
return users.size();
}
public static void updateUsers() {
for(String e : users) {
// send the user the necessary info to all users in the group
}
}
}