BigBug
BigBug

Reputation: 6290

itrerate through list of lists

so i have a lists within a list. i'm trying to grab the lists that are within this list. i know i can get the outer list data as seen bellow. But how do i grab the data for all the lists inside the outer list?

this is what i have:

public void iterateThroughList()
{
    Iterator<Test1> itr = databaseList.iterator();

    if (itr != null)
    {
        while (itr.hasNext())
        {
            Test1 test1= itr.next();

            System.out.println(test1.getName());
                            // set up itr2 to point to list within list??? how do i set this guy up?

            if(itr2 != null)
            {
                while(itr2.hasNext())
                {


                }
            }
        }
    }
}

Upvotes: 0

Views: 75

Answers (1)

&#211;scar L&#243;pez
&#211;scar L&#243;pez

Reputation: 235984

You can iterate through Test1 in the same way, as long as Test1 implements the Iterable interface.

Upvotes: 2

Related Questions