Bingchunmoli
V2EX  ›  问与答

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

  •  
  •   Bingchunmoli · Dec 5, 2023 · 1368 views
    This topic created in 893 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   ·   3044 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:40 · PVG 17:40 · LAX 02:40 · JFK 05:40
    ♥ Do have faith in what you're doing.