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(;

    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();
        }try {
            double number = Double.parseDouble(input);
        }catch (Exception e) { 
            System.out.println("Invalid Response! Please enter a whole number.");


Read more here:

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: