Title: Announcements
1Announcements Review
- Last Time basic type arrays
- // apple inventory
- int inventory 10, 20, 30
- String names McIntosh, Gala, Fuji)
- max 0
- for (int i 0 i lt names.length i)
- System.out.println(namesi)
- if (inventorymax lt inventoryi)
- max i
-
-
- System.out.println (Max inventory of
namesmax of inventorymax)
- Announcements
- Lab 4 FlightReservation
- Defining classes
- Due
- Thursday 10pm
- Exam
- 2/28 530-730pm
- GEO 2.216
2Operations Arrays
- int appleInventory 3, 10, 99
- appleInventory -gt
0 1 2
// operations on arrays of integers int i
inventory0 inventory1 30 inventory2 -
2 inventory2 inventory22 Arrays.sort(inve
ntory)
3Visualizing Arrays
- String appleNames "McIntosh", "Golden
Delicious", "Granny Smith" - appleNames -gt
-
4Strings vs Array of Strings
- String myApples new String("apples")
- String myApples -gt
0 1 2 3 4 5
// operations on string objects char c1
myApples.charAt(5) int position
myApples.indexOf(e) String sub
myApples.substring(0, 3) String sup
sub.concat(myApples) boolean same
sup.equals(sub)
// operations on string objects in an
array String names (Grapple, Red
Delicious, Fuji) char c1
names1.charAt(5) int position
names1.indexOf(e") String sub
names1.substring(0, 3) String sup
sub.concat(names1) boolean same
sup.equals(sub)
5More Questions?