Arrays
int myPhoneNo [] = {2,0,6, 5,4,3, 4,8,4,8};
int sum = 0;
for (int i=0; i < myPhoneNo.length; i++) {
sum += myPhoneNo[i];
}
int squares [];
squares = new int[10];
for (int i = 0; i < 10; i++) squares[i] = i*i;
// arrays are clonable:
int copyOfPhoneNo [];
copyOfPhoneNo = myPhoneNo.clone();
Previous slide
Back to first slide
View graphic version