Making Arrays
For Each Loops
Arrays
Code
100

make an array with test grades of 80, 88, and 89


int [] testGrades = {80,88,89}

100

Example of for each loop

for (int number: numbers) 

{
      System.out.println(number);

}

100

a collection of values in an organized way

What is an array?


100

What is the output after this code snippet runs?

int[] scores = {80, 92, 91, 68, 88}; for(int i = 0; i < scores.length; i--) { System.out.println(scores[i]); }

ArrayIndexOutOfBoundsException

200

write an array of 5 integers called list


int list [] = new int [5];



200

Example of for loop

for (int i=0; i<nums.length; i++)

{

System.out.println(nums[i]);

}

200

What are the values organized by?

index

200

String[] words = new String[10];
words[0] = "dog";
words[3] = "cat";
words[2] = "pig";
out.println( words[0] );
out.println( words[3] );
out.println( words[7] );
--------
State the output

dog
cat
null

400

int [] arr = {7,2,5,3,0,10};

for (int k=0;k<arr.length-1;k++)

{

if (arr[k]> arr [k+1])

System.out.println(k + " " + arr[k] + " ");

}

0 7 2 5 3 3