Added sample output

This commit is contained in:
Paul H 2025-03-03 13:36:35 +01:00
parent e868e84463
commit d1412b6a02

View File

@ -23,36 +23,48 @@ public class Main {
list.add((byte) -86); list.add((byte) -86);
list.add((byte) 3); list.add((byte) 3);
// list: [10, 5, -86, 3]
// add the element at the specified index // add the element at the specified index
list.add(3, (byte) 99); list.add(3, (byte) 99);
list.add(2, (byte) -40); list.add(2, (byte) -40);
// list: [10, 5, -40, -86, 99, 3]
// remove the element at the specified index // remove the element at the specified index
list.remove(2); list.remove(2);
list.remove(3); list.remove(3);
// list: [10, 5, -86, 3]
// set the element at the specified index // set the element at the specified index
list.set(1, (byte) 43); list.set(1, (byte) 43);
list.set(0, (byte) 8); list.set(0, (byte) 8);
// list: [8, 43, -86, 3]
// get the element at the specified index // get the element at the specified index
list.get(2); list.get(2); // returns: -86
list.get(1); list.get(1); // returns: 43
// get the size // get the size
list.size(); list.size(); // returns: 4
// does the list contain the specified element? // 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 // remove all elements inside the list
list.clear(); list.clear();
// return a copy of the list // list: []
list.copy();
// return a string of the form: [1, 84, 53]
list.toString();
// allow to use for each loop on list // allow to use for each loop on list
for (byte value : list) { for (byte value : list) {