1 /* 2 * Write a program, referencing the Primes program, by analogy, a program to 3 * name the streets in the french quarter of New Orleans. 4 */ 5 6 package arrayplay; 7 8 public class Streets { 9 10 public static void main(String[] args){ 11 String[] streets = new String[12]; 12 13 streets[0] = "Iberville"; 14 streets[1] = "Decatur"; 15 streets[2] = "Toulouse"; 16 streets[3] = "Bourbon"; 17 streets[4] = "Douphine"; 18 streets[5] = "Royal"; 19 streets[6] = "St Ann,"; 20 streets[7] = "St Peter"; 21 streets[8] = "Conti"; 22 streets[9] = "Exchange"; 23 streets[10] = "Bienville"; 24 streets[11] = "Dumaine"; 25 26 //display, labelled, the length of the featured array, the first element, the last element twice 27 System.out.println("length of streets array = " + streets.length); 28 System.out.println("first street = " + streets[0]); 29 System.out.println("last street = " + streets[11]); 30 System.out.println("last street = " + streets[streets.length-1]); 31 32 //display, labelled, the elements of the streets array 33 System.out.println("\nThe intitial streets array ..."); 34 int i = 0; 35 while ( i < streets.length ) { 36 System.out.println(streets[i]); 37 i = i + 1; 38 } 39 //swap the first and last elements of the streets array 40 String temp = streets[0]; 41 streets[0] = streets[streets.length-1]; 42 streets[streets.length-1] = temp; 43 44 //use a for loop to list the elements of the streets array, with the first and last elements swapped 45 System.out.println("\nThe final streets array ..."); 46 for ( int x = 0; x < streets.length; x = x +1){ 47 System.out.println(streets[x]); 48 } 49 } 50 } 51