JAVA-方法重载-两个数相等

package com.itheima;

//方法重载
/*在同一个类
方法名相同
参数类型不同或参数个数不同
需求:比较两个数是否相等,4种数据类型
*/

public class methodmedo11 {
    public static void main(String[] args) {
        System.out.println(x(10,20));
        System.out.println(x((short) 10,(short)20));
        System.out.println(x((byte)10,(byte)20));
        System.out.println(x(10l,20l));
    }
    public static boolean x(int a ,int b){
        System.out.println("int");
        return a==b;

    }
    public static boolean x(short a ,short b){
        System.out.println("short");
        return a==b;

    }
    public static boolean x(byte a ,byte b){
        System.out.println("byte");
        return a==b;

    }
    public static boolean x(long a ,long b){
        System.out.println("long");
        return a==b;

    }
}






posted @ 2022-08-02 00:04  NiceTwocu  阅读(64)  评论(0编辑  收藏  举报