Chapter 4

Exercise 4.9
public void listNotes()
{
    int index = 0;
    while(index < notes.size()) {
        System.out.println(index + ": " + notes.get(index));
        index++;
    }
}

Exercise 4.10

public void listNotes()
{
    int size = notes.size();
    int index = 0;
    while(index < size) {
        System.out.println(index + ": " + notes.get(index));
        index++;
    }
}
Exercise 4.11
public void showNote(int noteNumber)
{
if(noteNumber < 1) {
// This is not a valid note number, so do nothing.
}
else if(noteNumber <= numberOfNotes()) {
// This is a valid note number, so we can print it.
System.out.println(notes.get(noteNumber));
}
else {
// This is not a valid note number, so do nothing.
}
} public void removeNote(int noteNumber)
{
if(noteNumber < 1) {
// This is not a valid note number, so do nothing.
}
else if(noteNumber <= numberOfNotes()) {
// This is a valid note number.
notes.remove(noteNumber);
}
else {
// This is not a valid note number, so do nothing.
}
} public void listNotes() { int index = 0; while(index < notes.size()) { System.out.println((index+1) + ": " + notes.get(index)); index++; } }