关于错误的误解



因此,由于某种原因,编译器一直在说"输入"永远不会关闭。但是,该程序运行并执行。我只想知道为什么它一直说出来。这是语法。预先感谢。

import java.util.Scanner;
public class Problem1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter three numbers: ");
        int N1 = input.nextInt();
        int N2 = input.nextInt();
        int N3 = input.nextInt();       
        DoSort(N1, N2, N3);

    }
    public static void DoSort(int N1, int N2, int N3){
        if ((N1 < N2) && (N2 < N3)){
            System.out.println("The acsending order is " + N1 + " " + N2 + " " + N3);
            }
        if ((N1 > N2) && (N2 > N3)){
            System.out.println("The acsending order is " + N3 + " " + N2 + " " + N1);
            }
        if ((N1 < N2) && (N2 > N3) && (N1 < N3)){
            System.out.println("The acsending order is " + N1 + " " + N3 + " " + N2);
            }
        if ((N1 < N2) && (N2 > N3) && (N1 > N3)){
            System.out.println("The acsending order is " + N3 + " " + N1 + " " + N2);
            }
        }
    }

在此处输入图像描述

这只是一个警告,不幸的是您的情况不适用,因为您真的不想关闭System.in

在行之前添加@SuppressWarnings("resource")(也应该是快速修复)以摆脱警告。

最新更新