ArrayList<Rectangle> boxes = new ArrayList<Rectangle>();
ArrayList<String> professors = new ArrayList<String>();
professors.add("Horstmann"); professors.add("O'Brien");
professors.add(0,"Heller");
professors.set(1,"Kim");
Record your participation in Piazza clicker question Lesson15 Q1
Let's work with an array list containing string flower names
System.out.println(garden);
String name = professors.get(0);
String name = professors.get(i);
int size = professors.size()
String last = professors.get(professors.size() - 1);
String prof = professors.remove(1);
Record your participation in Piazza clicker question Lesson15 Q2
get the element at index 0 and assign it to a variable named temp get the element at index 1 and set it in index 0 set temp in index 1
[rose, petunia, marigold, daisy, zinnia]
[rose, petunia, daisy, zinnia, marigold]
professors.add("Wesley"); professors.add("Stamp");
for (String p: professors) { System.out.println(p); }
for (int i = 0; i < professors.size(); i++) { System.out.println(professors.get(i)); }
Record your participation in Piazza clicker question Lesson15 Q3
Using the garden project:
Record your participation in Piazza clicker question Lesson15 Q4
for each element in the ArrayList get the first letter of the string change the first letter to uppercase concatenate the uppercase letter with the rest of the word. set the element back in the ArrayList