Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import java.util.ArrayList;
import java.util.LinkedList;
public class ArrayELinkedList {
public static void main(String[] args) {
ArrayList<LinkedList<String>> arrayList = new ArrayList<>();
LinkedList<String> linked01 = new LinkedList<>();
linked01.add("A");
linked01.add("B");
LinkedList<String> linked02 = new LinkedList<>();
linked02.add("C");
arrayList.add(linked01);
arrayList.add(linked02);
//acessando o "B"
if (arrayList.get(0) != null){ //é sempre bom verificar antes de usar
System.out.println(arrayList.get(0).get(1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.