CS1 Standard Demo Page

The following text was written to the standard output stream when the Primes.java program was executed from Netbeans.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package arrayplay;

/**
 *
 * @author ecuevas
 */
public class Primes {

    /**
     * @param args the command line arguments
     */
    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]);
       
       System.out.println("\nThe initial array ...");
       int i = 0;
       while ( i < primes.length ) {
           System.out.println(primes[i]);
           i = i + 1;
       }
       
       int temp = primes[0];
       primes[0] = primes[primes.length-1];
       primes[primes.length-1] = temp;
       
       System.out.println("\nThe final array...");
       for (int x = 0; x < primes.length; x = x + 1 ) {
           System.out.println(primes[x]);   
       }
    }
    
}