Buggy code:
public class HighScoreActivity extends Activity { public static final int NUM_SCORES = 5 ; private ArrayList < String > initials ; private ArrayList < Integer > times ; private int mNewHighScoreIndex ; @ Override public void onCreate ( Bundle savedInstanceState ) { super . onCreate ( savedInstanceState ) ; setContentView ( activity_high_scores ) ; SharedPreferences prefs = getPreferences ( MODE_PRIVATE ) ; initials = new ArrayList < String > ( ) ; times = new ArrayList < Integer > ( ) ; String initialsString = prefs . getString ( "leaderBoardInitials" , "" ) ; StringTokenizer initialsTokenizer = new StringTokenizer ( initialsString , "," ) ; String timesString = prefs . getString ( "leaderBoardTimes" , "" ) ; StringTokenizer timesTokenizer = new StringTokenizer ( timesString , "," ) ; LinearLayout leaderBoardLayout = ( ( LinearLayout ) ( findViewById ( leader_board ) ) ) ; <START_BUG> while ( timesTokenizer . hasMoreTokens ( ) ) { <END_BUG> RelativeLayout leaderBoardEntry = new RelativeLayout ( this ) ; RelativeLayout . LayoutParams layoutParams = new RelativeLayout . LayoutParams ( 400 , LayoutParams . WRAP_CONTENT ) ; leaderBoardEntry . setLayoutParams ( layoutParams ) ; String time = timesTokenizer . nextToken ( ) ; String initial = initialsTokenizer . nextToken ( ) ; times . add ( Integer . parseInt ( time ) ) ; initials . add ( initial ) ; TextView leaderBoardTime = new TextView ( this ) ; leaderBoardTime . setText ( time ) ; RelativeLayout . LayoutParams timeLayoutParams = new RelativeLayout . LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; timeLayoutParams . addRule ( ALIGN_PARENT_END ) ; leaderBoardTime . setLayoutParams ( timeLayoutParams ) ; TextView leaderBoardInitials = new TextView ( this ) ; leaderBoardInitials . setText ( initial ) ; RelativeLayout . LayoutParams initialsLayoutParams = new RelativeLayout . LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ; initialsLayoutParams . addRule ( ALIGN_PARENT_START ) ; leaderBoardInitials . setLayoutParams ( initialsLayoutParams ) ; leaderBoardEntry . addView ( leaderBoardInitials ) ; leaderBoardEntry . addView ( leaderBoardTime ) ; leaderBoardLayout . addView ( leaderBoardEntry ) ; } if ( ( times . size ( ) ) == 0 ) { TextView highScoresLabel = ( ( TextView ) ( findViewById ( high_scores_label ) ) ) ; highScoresLabel . setVisibility ( GONE ) ; leaderBoardLayout . setVisibility ( GONE ) ; } Intent intent = getIntent ( ) ; int time = intent . getIntExtra ( EXTRA_TIME , ( - 1 ) ) ; mNewHighScoreIndex = - 1 ; if ( time != ( - 1 ) ) { for ( int i = 0 ; i < ( times . size ( ) ) ; i ++ ) { if ( time < ( times . get ( i ) ) ) { times . add ( i , time ) ; mNewHighScoreIndex = i ; break ; } } if ( ( ( times . size ( ) ) < ( HighScoreActivity . NUM_SCORES ) ) && ( ( mNewHighScoreIndex ) == ( - 1 ) ) ) { times . add ( time ) ; mNewHighScoreIndex = ( times . size ( ) ) - 1 ; } String resultsString = "" ; if ( ( mNewHighScoreIndex ) != ( - 1 ) ) { resultsString += "New<seq2seq4repair_space>high<seq2seq4repair_space>score!<seq2seq4repair_space>" ; EditText initialsEditText = ( ( EditText ) ( findViewById ( R . id . initials ) ) ) ; initialsEditText . setVisibility ( VISIBLE ) ; } resultsString += ( "You<seq2seq4repair_space>took<seq2seq4repair_space>" + time ) + "<seq2seq4repair_space>seconds<seq2seq4repair_space>to<seq2seq4repair_space>score<seq2seq4repair_space>5<seq2seq4repair_space>goals!" ; TextView resultsTextView = ( ( TextView ) ( findViewById ( results ) ) ) ; resultsTextView . setText ( resultsString ) ; } else { TextView gameOverLabel = ( ( TextView ) ( findViewById ( game_over_label ) ) ) ; gameOverLabel . setVisibility ( GONE ) ; TextView resultsTextView = ( ( TextView ) ( findViewById ( results ) ) ) ; resultsTextView . setVisibility ( GONE ) ; } } @ Override public void onBackPressed ( ) { } public void onDoneClicked ( View v ) { } }

Fix:
while ( ( timesTokenizer . hasMoreTokens ( ) ) && ( initialsTokenizer . hasMoreTokens ( ) ) ) {