How do I fix the "java.util.InputMismatchException" error in my Java program?

You’ve got the input issue under control now, but I noticed another little bug in your code that could cause trouble later: the way you’re comparing strings.

In Java, == checks for reference equality, not content equality. Since area[j] is a String object, using == might not give the expected result. To compare string values, use the .equals() method instead.

Here’s the corrected part of your search logic:

if (search.equals(area[j]))  // ✅ This correctly compares string values

Pros: This ensures that the program correctly checks if the search string matches any area.

Cons: It’s a small detail, but you just need to remember to use .equals() when comparing strings.