gpt4 book ai didi

java - 对象与字符串方法

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:02:57 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Overloaded method selection based on the parameter’s real type
How is an overloaded method choosen when a parameter is the literal null value?

当我执行下面的代码时,我得到以下输出:

Method with String argument Called ..."

为什么?

public class StringObjectPOC {

public static void test(Object o) {
System.out.println("Method with Object argument Called ...");
}
public static void test(String str){
System.out.println("Method with String argument Called ...");
}
public static void main(String[] args) {
StringObjectPOC.test(null);
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com