# Java Part 3 - missing step in collections section

**URL:** <https://forum.codewithmosh.com/t/java-part-3-missing-step-in-collections-section/1821>\
**Category:** Java\
**Created:** [January 10, 2021, 6:00pm UTC](https://forum.codewithmosh.com/t/java-part-3-missing-step-in-collections-section/1821 "2021-01-10T18:00:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slavimir](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/slavimir/32/185_2.png) [@Slavimir](https://forum.codewithmosh.com/u/Slavimir)\
**Post date:** [January 10, 2021, 6:00pm UTC](https://forum.codewithmosh.com/t/java-part-3-missing-step-in-collections-section/1821/1 "2021-01-10T18:00:23Z")

</div>

Hi,  
in a video number 7 in collections section, you did not record creation of class ListDemo.

Slavimir

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [August 16, 2022, 12:56am UTC](https://forum.codewithmosh.com/t/java-part-3-missing-step-in-collections-section/1821/2 "2022-08-16T00:56:46Z")

</div>

The ListDemo class was part of the [source code](https://cdn.fs.teachablecdn.com/iaf7XyHzT2qz1c4aAyti) provided by the course which is probably why there is no video where Mosh creates the class.

Since it is such a trivial demonstration of how to use collections I will reproduce it here:

```java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ListDemo {
  public static void show() {
    List<String> list = new ArrayList<>();
    list.add("a");
    list.add("b");
    list.add("c");

    // Add an item at a given index
    list.add(0, "!");

    // We can add multiple items in one go
    Collections.addAll(list, "a", "b", "c");

    var first = list.get(0);
    list.set(0, "!!");

    list.remove(0);

    var index = list.indexOf("a");
    var lastIndex = list.lastIndexOf("a");

    System.out.println(list.subList(0, 2));
  }
}

```

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [August 16, 2022, 2:02am UTC](https://forum.codewithmosh.com/t/java-part-3-missing-step-in-collections-section/1821/3 "2022-08-16T02:02:58Z")

</div>

Also…

> **[7- The List Interface](https://codewithmosh.com/courses/711980/lectures/12836262)**
>
> All about Exceptions, Generics, Collections, Lambdas, Streams, Multi-threading and Asynchronous Programming
