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