codeKingW 2023-03-13 20:52 采纳率: 33.3%
浏览 19

为什么输出结果是long啊


public class test {
    public static void main(String[] args) {
        Foo foo = new Foo();
        foo.test(1);
    }
}

class Foo {
    void test(byte a) {
        System.out.println("byte");
    }

    void test(int... a) {
        System.out.println("int...");
    }

    void test(short a) {
        System.out.println("short");
    }

    void test(long a) {
        System.out.println("long");
    }
}

为什么输出结果是long啊。

  • 写回答

4条回答 默认 最新

  • 快乐鹦鹉 2023-03-13 20:55
    关注

    int类型后面为啥加...呢? 整型常量默认是int型,四个重载函数与int最接近的是long型,把...去掉的话,才是int型

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 3月13日

悬赏问题

  • ¥15 用C语言完成一个复杂的游戏
  • ¥15 如何批量更改很多个文件夹里的文件名中包含文件夹名?
  • ¥50 MTK手机模拟HID鼠标出现卡顿
  • ¥20 求下下面这个数据结构代码
  • ¥15 路由器考试怎么办,有懂行的吗 ,eNSP
  • ¥20 前端 二进制文件流图片转化异常
  • ¥15 github上的这个C语言项目如何跑起来
  • ¥15 java 判断某个数 区间是否存在
  • ¥15 appium控制多个雷电模拟器问题
  • ¥15 C# iMobileDevice