Notizen
Arrays in Java
Inhalt der Notizen (2)
Seite 1
An array is a group of like-typed variables that are referred to by a common name.
In Java all arrays are dynamically allocated.
The direct superclass of an array type is Object.
Declaration:
int intArray[]; or int[] intArray;
When an array us declared, only a reference of array is created. To actually create or give memory to array:
var-name = new type [size];
int intArray[]; //declaring array intArray = new int[20]; // allocating memory to array
int[] intArray = new int[20]; // combining both statements in one
The elements in the array allocated by new will automatically be initialized to zero (for numeric types), false (for boolean), or null (for reference types)
Student[] arr = new Student[7]; //student is a user-defined class
Seite 2
Informationen
- Beschreibung
- Arrays Notiz am Arrays in Java, erstellt von Pranjal Deshmukh am 28/05/2018.
- Erstellt von
- Pranjal Deshmukh
- Aufrufe
- 0
- Bewertung