diff --git a/list/src/main/java/de/vivi/list/Main.java b/list/src/main/java/de/vivi/list/Main.java index 01e2ff7..7995749 100644 --- a/list/src/main/java/de/vivi/list/Main.java +++ b/list/src/main/java/de/vivi/list/Main.java @@ -23,36 +23,48 @@ public class Main { list.add((byte) -86); list.add((byte) 3); + // list: [10, 5, -86, 3] + // add the element at the specified index list.add(3, (byte) 99); list.add(2, (byte) -40); + // list: [10, 5, -40, -86, 99, 3] + // remove the element at the specified index list.remove(2); list.remove(3); + // list: [10, 5, -86, 3] + // set the element at the specified index list.set(1, (byte) 43); list.set(0, (byte) 8); + // list: [8, 43, -86, 3] + // get the element at the specified index - list.get(2); - list.get(1); + list.get(2); // returns: -86 + list.get(1); // returns: 43 // get the size - list.size(); + list.size(); // returns: 4 // does the list contain the specified element? - list.contains(43); + list.contains(43); // returns: true + list.contains(4); // returns: false + + // return a string of the form: [1, 84, 53] + list.toString(); // returns: "[8, 43, -86, 3]" + + // return a copy of the list + list.copy(); // returns: [8, 43, -86, 3] + // remove all elements inside the list list.clear(); - // return a copy of the list - list.copy(); - - // return a string of the form: [1, 84, 53] - list.toString(); + // list: [] // allow to use for each loop on list for (byte value : list) {