javaobjectarraylistgetter-setterobject-to-string

How do I return an ArrayList<String> from ArrayList<ArrayList<String>>.get()


I have an ArrayList like : ArrayList<ArrayList<String>> test

for(int i = 0; i < test.size(); i++) {
    ArrayList temp = test.get(i);
}

It turns out now, that I cannot do Arrays.deepToString(temp.toArray()) since temp is an Object and not < ArrayList< String>>.

Also, I am doing temp1.contains(temp.get()) temp1 and temp2 are actually objects with the same values < ArrayList< String>>. They even have some common ArrayLists within them. However, due to this Object problem, this does not work.

Is there any way by which I can basically return an ArrayList or so instead of an object so that I can get the .contains() method to work. As I said... the ArrayList within temp has the same number of columns, some with the same values.

Please help me out.


Solution

  • ArrayList temp = test.get(i);
    

    should be

    ArrayList<String> temp = test.get(i);