I am having a little trouble figuring this one out. Basically, I am reading Head First
Java and I am trying to write a method that
gets some user input, but if the user input doesn't match one of the Strings in an ArrayList, then to return "invalid". I am just a beginner, so the code closely resembles the code given in chapter 5 of the book for getting user input.
basically, this won't compile and it says that the first "return "invalid"" line is unreachable.. I'ts a problem I can get around, but I was just wondering why the compiler thinks this is unreachable. I mean, it's just a simple if/else, right? If I get rid of the second return invalid line, it complies fine though. Not a big problem, just trying to understand how the method is compiling. Shouldn't it not care that there are two lines that say return "invalid"? If that makes any sense.