uni

Thing1's amazing uni repo
Log | Files | Refs | Submodules

24.02.26.md (894B)


      1 # 24/02/26
      2 
      3 - you can use an ArrayList in java (linked list sorta?)
      4 - ArrayList is the implementation of `List` (interface) in java, which is an extension of a `Collection` in java
      5 - ArrayList is part of `java.util`
      6 - `List names = new ArrayList();`
      7     - we can see it is of type `List`, as `List` is an interface
      8     - we can limit the type of a List to a single type via `List<String> names = new ArrayList<>();`
      9 - `List` has the following methods
     10     - `void add(Obj o)` appends element
     11     - `int size()` gets the size
     12     - `void set(int index, Obj o)` sets element at
     13 - Since `ArrayList` is an instate of `List`, you can create it via `ArrayList l = new ArrayList()`
     14 - It cant store privative data types, only objects, so you will need to put primitives into an object (boxing)
     15 
     16 - The `Collections` class is a static class containing methods to operate on a `Collection`, such as `List`