62,621
社区成员
发帖
与我相关
我的任务
分享
import java.util.Scanner;
public class s {
public static void main(String [] args){
Scanner in = new Scanner(System.in);
System.out.println("Enter three number,please");
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
max(a,b,c);
in.close();
}
/*----max method part----*/
static void max(int a,int b,int c){
int t = 0;
if(a<b){
t=a;a=b;b=t;
}
if(a<c){
t=a;a=c;c=t;
}
if(b<c){
t=b;b=c;c=t;
}
System.out.println("Sorted Order : "+a+" "+b+" "+c);
}
}
Enter three number,please
3 4 5
Sorted Order : 5 4 3
还有一个错误就是你调用max没有传参。

int void max(int a,int b, int c, int t)
这一句中有两中返回类型啦大哥,按你程序的意思函数体本意是直接输出最大值,所以去掉void就OK啦
推荐你看《JAVA2核心技术第1卷.基础知识7th.pdf》