How to remove a user from an Array List?

后端 未结 1 554
一向
一向 2021-01-28 16:03
package main;
import java.util.ArrayList;

public class UserGroup {

  ArrayList userGroup = new ArrayList<>();
  User userOne;
  public UserGroup() {
         


        
相关标签:
1条回答
  • 2021-01-28 16:16

    It's working good :

    `  public static void main(String[] args) {
        UserGroup MyUser = new UserGroup();
        for (User curUser : MyUser.getUserGroup()) {
            System.out.println(curUser.toString());
          }
        MyUser.removeFirstUser();
        System.out.println("your user removed!");
        for (User curUser : MyUser.getUserGroup()) {
            System.out.println(curUser.toString());
          }
      }`
    

    RESULT :

    `User@4554617c 1
    User@74a14482 2
    User@1540e19d 3
    your user removed!
    User@74a14482 1
    User@1540e19d 2`
    
    0 讨论(0)
提交回复
热议问题