how can i understand what is an Unreachable code in my code can you take a look?

it says that the TRY .....CATCH is unreachable

i am trying to use ArrayList to make the code work

public static void main(String[] args) { Scanner in = new Scanner(System.in);

    ArrayList<Double> userInput = new ArrayList<Double>();
      
   boolean validNum=false;   
   do {   System.out.println("Please enter a number (or just hit enter to finish):");
        String input= in.nextLine();
        if(input.equals(""));{
            break;
        }try {
            double number = Double.parseDouble(input);
            userInput.add(number);
            validNum=true;
        }catch (Exception e) { 
            System.out.println("Invalid Response! Please enter a whole number.");
        }
  
   }while(!validNum);

}



Read more here: https://stackoverflow.com/questions/67929436/how-can-i-understand-what-is-anunreachable-code-in-my-code-can-you-take-a-look

Content Attribution

This content was originally published by Kennedy K at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: