1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Can't understand how to return an index number from an ArrayList

Discussion in 'Java' started by trojansc82, Nov 15, 2008.

  1. trojansc82

    trojansc82 New Member

    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++;
    }
    }
    
    
    
     

Share This Page