package arrayplay; public class Primes { public static void main(String[] args) { int[] primes = new int[4]; primes[0] = 2; primes[1] = 3; primes[2] = 5; primes[3] = 7; System.out.println("length of primes array = " + primes.length); System.out.println("first prime =" + primes[0]); System.out.println("last prime = " + primes[3]); System.out.println("last prime = " + primes[primes.length -1]); //!!: it doesn't need the empty parenthesis after .length @@ NO .length() System.out.println("\nThe initial array ... "); int i = 0; while (i < primes.length) { System.out.println(primes[i]); i = i +1; } //What the heck is this? Is that a loop? int temp = primes[0]; primes[0] = primes[primes.length -1 ]; primes[primes.length -1 ] = temp; //the same loop as like the initial array System.out.println("\nThe final array..."); for(int x = 0; x<primes.length;x=x+1) { System.out.println(primes[x]); } /******************************************************************** /* I think those three chunks of commands represent the same loop, but /*... in three different way /********************************************************************/ } }