一:设置List集合数据
List<String> userIds = new ArrayList<>();
userIds.add("10010");
userIds.add("10011");
userIds.add("10012");
二:取出List集合的值,放入GroupMember对象数组中
GroupMember[] members = new GroupMember[userIds.size()];
for(int i=0;i<userIds.size();i++){
GroupMember groupMember = new GroupMember();
groupMember.setId(userIds.get(i));
members[i] = groupMember;
System.out.println(userIds.get(i));
}
三:使用循环打印放入GroupMember对象数组的值
//增强for循环
for(GroupMember gm : members) {
System.out.println("增强for循环:" + gm.getId());
}
//普通循环
for (int i = 0; i< members.length; i++){
System.out.println("普通for循环:" + members[i].getId());
}