资源泄漏:“读者”从未关闭

时间:2020-06-01 08:30:19

标签: java resources

package calculatorop.java;
import java.util.Scanner;

public class Calculatorop {

    public static void main(String[] args) {

        Scanner reader = new Scanner(System.in);
        System.out.print("Enter two numbers: ");

        // nextDouble() reads the next double from the keyboard
        double first = reader.nextDouble();
        double second = reader.nextDouble();

        System.out.print("Enter an operator (+, -, *, /): ");
        char operator = reader.next().charAt(0);

0 个答案:

没有答案