this block of code going straight to break in java

Posted by user2914851 on Stack Overflow See other posts from Stack Overflow or by user2914851
Published on 2013-10-25T03:48:40Z Indexed on 2013/10/25 3:53 UTC
Read the original article Hit count: 71

Filed under:
|
|

I have this block in a switch case statement that when selected, just breaks and presents me with the main menu again.

 System.out.println("Choose a competitor surname");
    String competitorChoice2 = input.nextLine();
    int lowestSpeed = Integer.MAX_VALUE;
    int highestSpeed = 0;

    for(int j = 0; j < clipArray.length; j++) {

        if(clipArray[j] != null) {
            if(competitorChoice2.equals(clipArray[j].getSurname())) {
                if(clipArray[j].getSpeed() > clipArray[highestSpeed].getSpeed()) {
                    highestSpeed = j;
                }
            }
        }
    }

    for(int i = 0; i < clipArray.length; i++) {

        if(clipArray[i] != null) {
            if(competitorChoice2.equals(clipArray[i].getSurname())) {
                if(clipArray[i].getSpeed() < clipArray[lowestSpeed].getSpeed()) {
                    lowestSpeed = i;
                }
            }
        }
   }  

   for(int h = lowestSpeed; h < highestSpeed; h++ ) {

       System.out.println(""+clipArray[h].getLength());
   }

I have an array of objects and each object has a surname and a speed.

I want the user to choose a surname and display the speeds of all of their clips from lowest to highest.

when I select this option it just breaks and brings me back to the main menu

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays