I have a private ArrayList in a class and I'd like to be able to access it outside of this class, what would be the proper way to do this? Right now I've just made the ArrayList public but I would like to allow it to be private. Should I just create a new ArrayList in my Main and pass it to the private ArrayList method to populate it and return it or is there a better way?

4 Years
Discussion Span
Last Post by NormR1

One way is to have accessor (get/set) methods in the class that owns the arraylist.
If you are going to populate it in another method, have that method create it, populate it and return it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.