@Test
void contextLoads02(){
Map<String, Object> hashMap = new HashMap<>();
hashMap.put("a","1");
hashMap.put("b",null);
hashMap.put("c","3");
for(Map.Entry<String, Object> moEntry : hashMap.entrySet()){
try {
boolean equals = moEntry.getValue().equals("1");
System.out.println(moEntry.getKey() + "," + moEntry.getValue() +","+ equals);
} catch (Exception e) {
e.printStackTrace();
System.out.println("异常");
continue; //加上continue 出现异常后会执行后面的操作,打印11 ,若不加continue则不会打印11,直接进行下一个循环
}
System.out.println("11");
}
}
参考:https://blog.csdn.net/weixin_49419695/article/details/126275807
标签:exception,java,继续执行,continue,System,equals,moEntry,out,hashMap From: https://www.cnblogs.com/treeofb/p/16849624.html