Streets.java
1    package arraylistplay;
2    
3    import java.util.ArrayList;
4    
5    public class Streets {
6        public static void main(String[] args) {
7            ArrayList<String> streets = new ArrayList<>();
8    
9            streets.add("Iberville");
10           streets.add("Decatur");
11           streets.add("Toulouse");
12           streets.add("Bourbon");
13           streets.add("Dauphine");
14           streets.add("Royal");
15           streets.add("St Ann");
16           streets.add("St Peter");
17           streets.add("Conti");
18           streets.add("Exchange");
19           streets.add("Bienville");
20           streets.add("Dumaine");
21   
22           System.out.println("size of streets list = " + streets.size());
23           System.out.println("first street = " + streets.get(0));
24           System.out.println("last street = " + streets.get(11));
25           System.out.println("last street = " + streets.get(streets.size()-1));
26   
27           System.out.println("\nThe initial list... ");
28           for ( String street : streets) {
29               System.out.println(street);
30           }
31   
32           String temp = streets.get(0);
33           streets.set(0, streets.get(streets.size()-1));
34           streets.set(streets.size()-1, temp);
35   
36           System.out.println("\nThe final list... ");
37           for ( String street : streets ) {
38               System.out.println(street);
39           }
40       }
41   }
42