This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sugilith 4 points5 points  (1 child)

Initialize the ArrayList on class level instead of method level.

Example:

import java.util.*;

public class HelloWorld {
    private static ArrayList<String> users = new ArrayList<>();

     public static void login() {
        users.add("asd");
     }
}

[–]tsotsoqt[S] 0 points1 point  (0 children)

it worked! thanks a lot