Java 将字符串键从hashmap更改为int

Java 将字符串键从hashmap更改为int,java,hashmap,int,Java,Hashmap,Int,我有一个hashmap,字符串作为键,对象作为值 private HashMap<String, object> asdf; 我需要将“2009”作为int检索。我尝试了一些parseInt技巧,但没有成功。也许我做错了 有什么提示、建议、指导吗 (Map.Entry:Map.entrySet()){ (Map.Entry<String, Object> entry : map.entrySet()) { //

我有一个hashmap,字符串作为键,对象作为值

 private HashMap<String, object> asdf;
我需要将“2009”作为int检索。我尝试了一些parseInt技巧,但没有成功。也许我做错了

有什么提示、建议、指导吗

(Map.Entry:Map.entrySet()){
            (Map.Entry<String, Object> entry : map.entrySet()) {
                 //We split up the string into array using ":" as filter, we remove the white space, and return the first array component
                 String key = entry.getKey().split(":")[0].trim(); 
                 int year = Integer.parseInt(key);
             }
//我们使用“:”将字符串拆分为数组,作为过滤器,删除空白,并返回第一个数组组件 字符串key=entry.getKey().split(“:”[0].trim(); int year=Integer.parseInt(键); }
展示这些“parseInt技巧”哈希映射有什么问题?这仅仅是关于解析字符串,还是我遗漏了什么?我尝试了类似“Integer.parseInt(objectArray.keySet());”这样的方法和'NumberFormat.getInstance().parse(objectArray.keySet())'但它们的keySet()似乎不兼容。哦,因为keySet只是返回一个键,而不是一个字符串。您能添加一些词来描述您的解决方案吗?
            (Map.Entry<String, Object> entry : map.entrySet()) {
                 //We split up the string into array using ":" as filter, we remove the white space, and return the first array component
                 String key = entry.getKey().split(":")[0].trim(); 
                 int year = Integer.parseInt(key);
             }