GoConqr has a new look! Let us know what you think.

Notes

Arrays in Java

Pranjal Deshmukh Arrays English 2 pages

Content of the notes (2)

Page 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

Page 2

Information

Description
Arrays Note on Arrays in Java, created by Pranjal Deshmukh on 28/05/2018.
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?