Java Error “Exception in thread “main” java.util.InputMismatchException” On an Array program

First of all, remember to indent your code for readability.

Concept 1.

for (int i=0;i<=9;i++){

area[i]=s.next();// Use this for String Input

pincode[i]=s.nextInt();

s.nextLine();//Use this for going to next line of input

}

Concept 2.

if(search.compareTo(area[j])==0){ 

// compare Strings using compareTo method (which returns 0 if equal

Rest of your code and concepts are correct 🙂

Leave a Comment

error code: 523