Mindmap
Array

Mind map: Java arrays
Inhalt der Mindmap
Array
Very similar to dictionaries in Python
- The size of an array can't be change
How to declare/instantiate: elementType[] varName = new elementType[arraySize];
- Example:String[] stringHolder = new String[5]
- Setting the values of an array: varName[index] = value;
- Checking the length: varName.length (no parentheses)
- Can also initialize it like this: String[] stringHolder = {value1, value2, value3}
Indexing through an array: for-each loop
- Example: for(elementType element: nameofArray)
- for(double d1: stringHolder)
- Example: for(elementType element: nameofArray)
Two Dimensional Arrays
- Declare: int[][] array2d;
- array2d = new int[3][10]
- Declare: int[][] array2d;
Copying Arrays:
- Use a loop to copy the individual elements
- use static arraycopy method in System class
- arraycopy(sourceArray, sourcePosition, targetArray, targetPosition, length)
- Use clone method to copy arrays.
Informationen
- Beschreibung
- Computer Science Mindmap am Array, erstellt von Tate Johnson am 27/04/2021.
- Erstellt von
- Tate Johnson
- Aufrufe
- 59
- Tags
- Bewertung