1package com.journaldev.examples;
2
3import java.util.ArrayList;
4import java.util.List;
5
6public class ListAddExamples {
7
8 public static void main(String[] args) {
9
10 List<String> vowels = new ArrayList<>();
11
12 vowels.add("A"); // [A]
13 vowels.add("E"); // [A, E]
14 vowels.add("U"); // [A, E, U]
15
16 System.out.println(vowels); // [A, E, U]
17
18 vowels.add(2, "I"); // [A, E, I, U]
19 vowels.add(3, "O"); // [A, E, I, O, U]
20
21 System.out.println(vowels); // [A, E, I, O, U]
22 }
23}
1List<SomePojo> list = new ArrayList<SomePojo>();
2
3List<SomePojo> anotherList = new ArrayList<SomePojo>();
4anotherList.add(list);