java中3个数怎样比较大小

[复制链接]
查看11 | 回复5 | 2010-6-9 15:14:01 | 显示全部楼层 |阅读模式
public class Compare{public static void main(String args[]){ bigger(55,55,55);}public static void bigger(int i,int j,int k){ if(i>j) {
System.out.println("第一个数值要比第二个大,下面比较第一个和第三个的大小关系");
if(i<k)
{
System.out.println("第三个数值最大");
System.out.println("最大数值是"+k);
}
else if(
回复

使用道具 举报

千问 | 2010-6-9 15:14:01 | 显示全部楼层
import java.util.Arrays;public class Test2 { public static void main(String[] args) {int[] arr = new int[]{8, 45, 6};
//按升序排列Arrays.sort(arr);
回复

使用道具 举报

千问 | 2010-6-9 15:14:01 | 显示全部楼层
package com.dust;public class Compare { int a, b, c; // 三个数 int i; // 状态 public Compare(int a, int b, int c) {this.a = a;this.b = b;this.c = c; } publ
回复

使用道具 举报

千问 | 2010-6-9 15:14:01 | 显示全部楼层
使用Arrays类可对任何数组进行排序,并可自定义比较器int[] num = new int[]{5,8,2};Arrays.sort(num);System.out.println("最小的数:"+num[0]);System.out.println("中间的数:"+num[1]);System.out.println("最大
回复

使用道具 举报

千问 | 2010-6-9 15:14:01 | 显示全部楼层
public class Test {
public int getMax(int a, int b, int c) {
return Math.max(Math.max(a, b), c);
}
public static void main(String[] args) {
Test te
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行