执行以下部分时,getValue()
方法中出现错误。我尝试将 s 作为内部参数传递getValue()
。在那里也行不通。
//Mymap<String,Integer>()
while(in.hasNext()){
//in is a scanner object
String s = in.next();
// Write code here
//s is a string to be searched
if (Mymap.containsKey(s)) {
//the value corresponding to s is to be retrieved
Integer i= (Integer)Mymap.getValue();
System.out.println(i);
System.out.println(s+"="+Mymap.get(s));
} else {
System.out.println("Not found");
}
}