Bingchunmoli
V2EX  ›  问与答

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

  •  
  •   Bingchunmoli · Dec 5, 2023 · 1835 views
    This topic created in 1071 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
    zjp
    Dec 5, 2023❤️1
    1
    方法重载,有多个签名匹配
    nothingistrue
    nothingistrue
    Dec 5, 2023
    2
    因为 createDeserializationContext 有重载。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1608 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 00:03 · PVG 08:03 · LAX 16:03 · JFK 19:03
    ♥ Do have faith in what you're doing.