String song = " ";
System.out.print("Enter song number: ");
songNum = stdIn.nextLine();
songIndex = songs.indexOf(songNum, 0);
eolIndex = songs.indexOf('\n', songIndex);
song = songs.substring(songIndex, eolIndex);
System.out.println(song);
Tuesday, September 29, 2009
Monday, September 28, 2009
Exercise 6
int fromIndex=0;
do{
foundIndex = songs.indexOf(searchText, fromIndex);
if(foundIndex>=0){
count++;
fromIndex=foundIndex+1;
}
}while(foundIndex>=0);
do{
foundIndex = songs.indexOf(searchText, fromIndex);
if(foundIndex>=0){
count++;
fromIndex=foundIndex+1;
}
}while(foundIndex>=0);
Subscribe to:
Posts (Atom)