/home/ssingh6/NetBeansProjects/CS1/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 ssingh6
11  */
12 public class Primes {
13 
14     /**
15      * @param args the command line arguments
16      */
17     public static void main(String[] args) {
18        int[] primes = new int[4];
19        primes[0]=2;
20        primes[1]=3;
21        primes[2]=5;
22        primes[3]=7;
23        System.out.println("length of primes array= "+primes.length);
24        System.out.println("first prime =" +primes[0]);
25        System.out.println("last prime =" +primes[3]);
26        System.out.println("last prime =" +primes[primes.length-1]);
27        System.out.println("\n The intial array....");
28        int i=0;
29        while(i<primes.length) {
30            System.out.println(primes[i]);
31            i=i+1;
32        }
33        int temp= primes[0];
34        primes[0]=primes[primes.length-1];
35        primes[primes.length-1]=temp;
36        System.out.println("\n The final array...");
37       for(int x=0; x<primes.length; x=x+1)
38        
39        {
40           System.out.println(primes[x]);
41        }
42            
43       
44     }
45     
46 }
47