Professional Documents
Culture Documents
ARRAYS
OVERVIEW
Array is one of the data structures used in any programming language. It is an organize
storage of data or objects each having the same name and each having the same type. As a
review, sample programs are given to the students for them to recall the purpose of array,
how to declare and initialize an array, and maximize the use of array as data structure.
LEARNING OUTCOMES
MATERIAL/S
ACTIVITIES
A. Type the following programs in JCreator or any Java compiler available in your
desktop or online:
1. Declaring and initializing Array:
public class dispArray {
public static void main(String[]args) {
String dog[]= new String[5];
dog [0]= “Rocky”;
dog [1]= “Whitey”;
dog [2]= “Blackie”;
dog [3]= “Brownie”;
dog [4]= “Pappie”;
for (int a=0; a<5; a++) {
System.out.println(dog[a]);
}
}
}
int temp=0;
System.out.println();
System.out.println("Sorted Array");
Page 2 of 3
Array List:
2 8 6 10 4
Sorted Array:
2 4 6 8 10
Page 3 of 3