关于map中取值null处理

     

       Map<String, Object>  responseMap  = new HashMap<String, Object>();
        String  userMessageId = responseMap.get("USER_MESSAGE_ID")+"";
        String  userException = responseMap.get("USER_EXCEPTION_OBJECT")+"";
        System.out.println(null==(responseMap.get("USER_EXCEPTION_OBJECT")));
        System.out.println(responseMap.get("USER_MESSAGE_ID")==null);
        System.out.println((userException).equals("null"));
        System.out.println(userException.equals(null));

返回接口 

true
true
true
false

在map中取值为null ,转换成String的时候  null 变成了“null”

开发谨记

猜你喜欢

转载自my.oschina.net/u/198077/blog/1817998