重载练习

package cn.itcast.day04.demo04;
/*
重载比较方法
 */
public class Demo02MethodOveroadSame {
    public static void main(String[] args) {
        System.out.println(isSame(10,10));
        System.out.println(isSame((short)20,(short)10));

    }
    public static boolean isSame(byte a,byte b){
        System.out.println("btye");
        boolean same;
        if (a==b){
            same = true;
        }else {
            same = false;
        }
        return same;
    }

    public static boolean isSame(short a, short b){
        System.out.println("short");
        boolean same = a == b ? true : false;
        return  same;
    }

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

    public static boolean isSame(long a, long b){
        System.out.println("long");
        if (a == b){
            return  true;
        }else{
            return  false;
        }
    }
}

 

posted @ 2020-03-11 20:28  汉魂县令  阅读(52)  评论(0)    收藏  举报