Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Can't understand how to return an index number from an ArrayList (http://www.go4expert.com/forums/understand-return-index-arraylist-t15145/)

trojansc82 16Nov2008 04:17

Can't understand how to return an index number from an ArrayList
 
I'm having trouble returning an index number based on a String search. I have a class called CD with a field of tracks. I am trying to search for the track number based on the String I provide.

Here is the search I have so far:

Code:

int index = 0;
boolean found = false;
while(index < tracks.size() && !found){
String track = tracks.get(index);
if(track.contains(searchString)){
found = true;
}
else{
index++;
}
}



All times are GMT +5.5. The time now is 22:08.