【发布时间】:2020-03-12 20:49:29
【问题描述】:
我从一些测验中获取了这段代码 sn-p,使用 IDE 我执行它并得到结果 long, long 但正确答案是 Byte, Byte,为什么我得到了不同的结果?该问题与JDK 11有关
public class Client {
static void doCalc(byte... a) {
System.out.print("byte...");
}
static void doCalc(long a, long b) {
System.out.print("long, long");
}
static void doCalc(Byte s1, Byte s2) {
System.out.print("Byte, Byte");
}
public static void main(String[] args) {
byte b = 5;
doCalc(b, b);
}
}
已编辑:
代码取自这里:Oracle Certification Overview and Sample Questions (第 13 页,问题:5)
【问题讨论】:
-
你确定不是
Byte b = 5;大写的B吗? -
我在 Java8 上也收到了
long, long仅供参考...不知道为什么说实话,也在等待答案:)
标签: java