判断两数之间的最大值

判断两数之间的最大值

可直接利用Java自带的函数(abc 绝对值函数)再结合三元运算符实现

public class TestMax {

	public static void main(String[] args) {
		
		System.out.println(max(5,6));
		
	}

	private static int max(int i, int j) {
		// TODO Auto-generated method stub
		//	abc 绝对值函数
		return Math.abs(i-j)==(i-j)?i:j;
	}
	
}
posted @ 2019-11-02 10:50  追风少年潇歌  阅读(51)  评论(0)    收藏  举报