V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Bingchunmoli
V2EX  ›  问与答

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

  •  
  •   Bingchunmoli · Dec 5, 2023 · 1346 views
    This topic created in 886 days ago, the information mentioned may be changed or developed.

    举一个例子 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  
       Dec 5, 2023   ❤️ 1
    方法重载,有多个签名匹配
    nothingistrue
        2
    nothingistrue  
       Dec 5, 2023
    因为 createDeserializationContext 有重载。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2537 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 00:28 · PVG 08:28 · LAX 17:28 · JFK 20:28
    ♥ Do have faith in what you're doing.