Sebastian Zeki
Sebastian Zeki

Reputation: 6874

How to use a returned ArrayList in another method

I think I am getting myself confused...I am calling a method (method B) which generates an array list. The calling is done from inside another method (method A). I am then trying to use the returned arrayList in method A but it seems to be empty. The arrayList generated in method B is not empty however so I think I've got some return ArrayList issue that I don't understand. Here is my code:

public void ExtractNew(String doc,String day) {

    ExtractTotal(docSlim,day);
}

public ArrayList<List<String>> ExtractTotal(String docSlim,String day) {
    ////Code for multidimensional arrayList creation omitted
            Arr2d.add(Arr);
            }
    }
    return Total;
}

Upvotes: 0

Views: 361

Answers (1)

Tom Mac
Tom Mac

Reputation: 9853

You're not adding to the Total ArrayList inside the ExtractTotal method.

Try this before returning it:

Total = Arr2d;

Assuming that Total is a class level variable here of course....

Upvotes: 1

Related Questions