fuck code.
import java.util.Map;
import java.util.HashMap;
public class Main {
private Map<String, String> map;
public Main() {
Map<String, String> map = new HashMap<String, String>();
map.put("a", "123");
map.put("b", "d");
map.put("c", "456");
System.out.println(getValueAsInt("a"));
System.out.println(getValueAsInt("b"));
System.out.println(getValueAsInt("c"));
}
public int getValueAsInt(String key) {
if(map.get(key) == null){
return -1;
} else {
int res;
try{
res = Integer.parseInt(map.get(key));
} catch(NumberFormatException e) {
e.printStackTrace();
res = -1;
}
return res;
}
}
public static void main(String args[]){
new Main();
}
}