/home/jfernan6/NetBeansProjects/CSX/src/arrayplay/Primes.java
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package arrayplay;
 7 
 8 /**
 9  *
10  * @author jfernan6
11  */
12 public class Primes {
13 
14     /**
15      * @param args the command line arguments
16      */
17     public static void main(String[] args) {
18        
19         int [] primes = new int [4];
20         
21         primes [0] = 2;
22         primes [1] = 3;
23         primes [2] = 5;
24         primes [3] = 7;
25         
26         System.out.println("length of primes array = " + primes.length);
27         System.out.println("first prime = " + primes [0]);
28         System.out.println("last prime = " + primes[3]);
29         System.out.println("last prime = " + primes[primes.length - 1]);
30         
31         System.out.println("\nThe intial array ...");
32         int i = 0;
33         while( i < primes.length ){
34                 System.out.println(primes[i]);
35                 i = i +1;
36         }
37          
38         int temp = primes [0];
39         primes[0] = primes[primes.length - 1];
40         primes[primes.length - 1] = temp ;
41         
42         System.out.println("\nThe final array ...");
43         for ( int x = 0; x < primes.length; x = x+1){
44             System.out.println(primes[x]);
45         }
46     }
47     
48 }
49