GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

ArrayLists

Eithne O'Sullivan Information Technology Englisch

Inhalt der Mindmap

ArrayLists

  1. Resizable-array implementation of the List interface.

    • is an abstraction from programmer manipuplation of Arrays
    • part of Collections API
  2. Implements all optional List operations

  3. elements can be any object type and null

    • uses generics<T>
  4. create new ArrayList object

    • ArrayList<String> list = new ArrayList<String>()
    • deafault size at creation is 10. can specify required size as constructor parameter
    • specify class name of objects it will hold in <>. can use empty <> after new.
    • Array is used as underlying hidden data structure
  5. size increases automatically if add to full arraylist

  6. METHODS

    • size: number of indices with elements
      • int x = list.size()
    • remove element
      • remove & return element at index i : E elem=list.remove(i);
      • remove 1st match of element e: boolean b = list.remove(e);
      • remove all elements: list.clear();
    • add element
      • add element at end: list.add("something")
      • insert at position of index: list.add(i, elem)
    • replace element: list.set(index, "something else");
    • get element at index i: E e= list.get(i);
    • list.contains(e)
    • list.isEmpty();
  7. for-each or enhanced for loop can be used

  8. ArrayList vs Array

    • AL: less efficient; not have convenient[ i] use; base type must be a class, not primitive(can use wrappers);
    • A: can't change in size - AL grow/shrink during use; A: need to keep cnt of elements in it- AL: does this auto; A: have NO methods - AL: powerful methods for manipulation

Informationen

Beschreibung
Information Technology Mindmap am ArrayLists, erstellt von Eithne O'Sullivan am 20/02/2018.
Erstellt von
Eithne O'Sullivan
Aufrufe
25
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck