Bingchunmoli
V2EX  ›  问与答

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

  •  
  •   Bingchunmoli · Dec 5, 2023 · 1630 views
    This topic created in 1008 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   ·   Privacy   ·   Solana   ·   952 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 21:34 · PVG 05:34 · LAX 14:34 · JFK 17:34
    ♥ Do have faith in what you're doing.