首页 > 编程知识 正文

map.get(key)空指针异常,遍历map的key和value

时间:2023-05-04 09:14:34 阅读:57279 作者:2715

我自己做班级方法{ string class name,方法名称; VectorparameterTypes; }然后,以Method为键值,写了地图。 然后,我可以在遍历所有输出此映射的密钥时输出我想要的一对.

我自己做班级方法{ string class name,方法名称; 矢量参数类型; }然后,以Method为键值,写了地图。 然后,当我遍历所有用于输出此映射的密钥时,我可以输出我想要的对象a的内容,但写Map.containsKey(a )将返回false。 我自己尝试过重写Object.equals方法,但还是没有用。 改写的equals方法如下。 公共蓝牙(对象以太网) if (! (方法实例)返回假; 方法通告程序=(方法)通告程序方法; if (! this.class name.equals (another.class name ) ) return false; if (! this.method name.equals (another.method name ) ) return false; if (this.parameter types==null another.parameter types!=null (返回假; if(this.Parametertypes!=null another.parameter types==null ) return false; if(this.parametertypes.size (!=another.parameterTypes.size () ) return false; for(intI=0; I

展开

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。