javaarray.pdf

(247 KB) Pobierz
623026934 UNPDF
Java Array
1
623026934.005.png 623026934.006.png
Agenda
What is an array
Declaration of an array
Instantiation of an array
Accessing array element
Array length
Multi-dimensional array
2
623026934.007.png
What is an Array?
3
623026934.008.png 623026934.001.png
Introduction to Arrays
Suppose we have here three variables of type int with
different identifiers for each variable.
int number1;
int number2;
int number3;
number1 = 1;
number2 = 2;
number3 = 3;
As you can see, it seems like a tedious task in order to just
initialize and use the variables especially if they are used for
the same purpose.
4
623026934.002.png
Introduction to Arrays
In Java and other programming languages, there is one
capability wherein we can use one variable to store a list of
data and manipulate them more efficiently. This type of
variable is called an array.
An array stores multiple data items of the same data type, in
a contiguous block of memory, divided into a number of
slots.
5
623026934.003.png 623026934.004.png
Zgłoś jeśli naruszono regulamin