C-2 方法重载,比较大小
2015-08-20 11:18
162 查看
/* 方法重载 比较两个数据是否相等,参数类型分别为 两个byte、两个short、两个int、两个long */ class FunctionTest{ public static void main(String[] args){ //测试 byte b1 = 3; byte b2 = 4; System.out.println("byte:"+compare(b1,b2)); //测试 int i1 = 11; int i2 = 11; System.out.println("int:"+compare(i1,i2)); //测试 short s1 = 7; short s2 = 9; System.out.println("short:"+compare(s1,s2)); //测试 long l1 = 7; long l2 = 9; System.out.println("long:"+compare(l1,l2)); } //byte类型 public static boolean compare(byte a, byte b){ System.out.println("byte:"); return a == b; } //int类型 public static boolean compare(int a, int b){ System.out.println("int:"); return a == b; } //short类型 public static boolean compare(short a, short b){ System.out.println("short:"); return a == b; } //long类型 public static boolean compare(long a, long b){ System.out.println("long:"); return a == b; } }
相关文章推荐
- 操作MySQL数据库相关代码
- Neutron Metering as a Service
- C#操作Active Directory(AD)详解
- 快学Scala习题解答—第四章 映射和元组
- POJ 2352 树状数组(线段树)
- ASP.NET巧妙利用repeater控件和checkBox控件实现批量操作
- volatile关键字的作用
- HTTP协议 (一) HTTP协议详解
- hdu1002(简单大数加法)
- Javascript(一)-10-(JS语句-循环语句)
- PHP session 存储方式
- Lighttpd交叉编译及使用
- qq第三方登录的调用
- 在Docker中使用ubuntu镜像搭建gitlab
- 数据库并发插入避免重复数据的问题
- fibonacci数列的递归与非递归实现
- centos关机与重启命令详解
- 使用Python求解最大公约数的实现方法
- log4j详解(二) XML 配置方式
- iOS动态类型和动态绑定