Good day. Tell the unreasonable newcomer the answer to the following question: We have 2 classes available: Main, Class1, Class2. In Maine, I create objects. In class1, this object is added to an ArrayList using a non-static method. I can not understand for myself how I can get this erylist in class 2?

Thanks in advance to everyone who tells

    1 answer 1

    In Class2 you need to add a method

     pulic void setList(List list){ this.list = list; } 

    After that, call it in the place where you need to transfer the list to class 2, and after that you can work with this list in class 2

    • Something does not work out ((Apparently a completely neglected case - Bogdan Mikhalchenko
    • @ Bogdan Mikhalchenko, well, the code in the studio! - Vladyslav Matviienko
    • Well .. What question is the answer .. - Newbie