Array Revision



Arrays II

containing Objects

in Classes and Methods

Arrays can contain primitive Java types or any type of objects.

Arrays can be used

in class definitions as attributes

in method definitions as parameters or return types

Array Revision

- collection of variables all of the same type (primitive types, Strings, objects), usually related in some way

- allows manipulation of data (easy sorting )

- Java arrays are implemented as objects (use of operator "new")

Syntax

elementType arrayName[ ] = new elementType[size];

Array declaration and creation

int[ ] numbers;

numbers = new int[10]; // 0 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download