/* package whatever; // don't place package name! */
import java.util.ArrayList;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
/* Lista Final */
ArrayList
<ArrayList
<String
>> List = new ArrayList
<ArrayList
<String
>>() {{
/* Cria uma List de frutas */
add( new ArrayList<String>() {{
add("Abacaxi");
add("Banana");
add("Cajá");
add("Caqui");
}} );
/* Cria uma List de armas */
add( new ArrayList<String>() {{
add("Parafal");
add("M4");
add("PT938");
add("AR-15");
}} );
/* Cria uma List de bandas */
add( new ArrayList<String>() {{
add("Evanescence");
add("Linkin Park");
add("Epica");
add("Xandria");
}} );
}};
/* Percorre a primeira lista */
for (int i
= 0; i
< List.
size(); i
++) {
/**
* Percorre as sublistas utilizando expressão Lambda (Java 8)
* Caso não utilize Java 8, substitua por um `for`
*/
List.
get(i
).
forEach( x
-> { });
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCS8qIExpc3RhIEZpbmFsICovCiAgICAgICAgQXJyYXlMaXN0PEFycmF5TGlzdDxTdHJpbmc+PiBMaXN0ID0gbmV3IEFycmF5TGlzdDxBcnJheUxpc3Q8U3RyaW5nPj4oKSB7ewoJCQkKCQkJLyogQ3JpYSB1bWEgTGlzdCBkZSBmcnV0YXMgKi8KCQkJYWRkKCBuZXcgQXJyYXlMaXN0PFN0cmluZz4oKSB7ewoJCQkJYWRkKCJBYmFjYXhpIik7CgkJCQlhZGQoIkJhbmFuYSIpOwoJCQkJYWRkK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