N = notes.size() - 1; while (N >= 0) { ... N = N-1; }
2. searchNotes(String s):
Prints the notes, with number, that contain the given string s as a
substring. To check if s is contained in the Nth note, use the library
contains() method as follows:
String note = notes.get(N);
if ( note.contains(s) ) {
// print note
}
3. totalLength():
Returns (not prints) the total length of all the notes; that is, the sum of
the individual note lengths. To get the length of the Nth note, use
String note = notes.get(N);
int len = note.length();
(Note that here as in other places, the declarations of variables note and len
as String and int respectively are shown on the same lines as the assignments of values,
but you are free to separate the two.)
4. longestNote():
Prints the longest note. To find the longest note, you will need a loop with two variables:
maxlen: initially 0,
the length of the longest note seen so far.
position: the number of the longest note.
As you loop through from 0 to notes.size(), if you find a longer note then you
update both variables above.
String note = notes.get(N); if (note.length() > maxlen) { // longer note found maxlen = note.size(); position = N; }After the completion of the loop, you print out notes.get(position), the note with the given position. Print out its number as well.
Email me your completed project.