I can't understand where is the error
When I use nextInt to read the input as int I recibe the error, but if I change the variable"a" in the last line with 0 the Code run. import java.util.HashMap; import java.util.Scanner; public class datass{ HashMap<Integer,String> points = new HashMap<Integer,String>(); public String search_in(int number){ return points.get(number); } public void add_row(int a,String name){ points.put(a,name); } } public class MyClass { public static void main(String[ ] args) { datass id_person = new datass(); Scanner pal = new Scanner(System.in); Scanner num = new Scanner(System.in); String words = pal.nextLine(); id_person.add_row(0,words); int a = num.nextInt(); System.out.println(id_person.search_in(a)); } }