经过大家的提点我已经我已经重写了代码,虽然仍然很笨拙,但是至少代码结构更加清晰了。不管怎么刚刚入门嘛也是一种解决方法。
代码现在是这样子:
```java
import java.util.Scanner;
public class MaxNumber {
public static void main(String[] args) {
Scanner input = new Scanner(
System.in);
System.out.print("Please enter four numbers: ");
int number1 = input.nextInt();
int number2 = input.nextInt();
int number3 = input.nextInt();
int number4 = input.nextInt();
int max = 0;
if (number1 > number2 && number1 > number3 && number1 > number4) {
max = number1;
}else if (number2 > number1 && number2 > number3 && number2 > number4) {
max = number2;
}else if (number3 > number1 && number3 > number2 && number3 > number4) {
max = number3;
}else if (number4 > number1 && number4 > number2 && number4 > number3) {
max = number4;
}else {
System.out.print("有特殊情况!");
}
System.out.print(max);
}
}
```