V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Bingchunmoli
V2EX  ?  问与答

Java 中调用方法使用 null 但显式强制类型转换为什么

  •  
  •   Bingchunmoli · 159 天前 · 439 次点击
    这是一个创建于 159 天前的主题,其中的信息可能已经有所发展或是发生改变。

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    举一个例子 jackson 中 ObjectMapper

    public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause) {
            return this.createDeserializationContext((JsonParser)null, this.getDeserializationConfig()).hasValueDeserializerFor(type, cause);
        }
    

    为什么这里不是 null 而是 (JsonParser)null

    zjp
        1
    zjp  
       159 天前   ?? 1
    方法重载,有多个签名匹配
    nothingistrue
        2
    nothingistrue  
       159 天前
    因为 createDeserializationContext 有重载。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   6100 人在线   最高记录 6547   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 84ms · UTC 03:18 · PVG 11:18 · LAX 20:18 · JFK 23:18
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com