Java扫描器不能在eclipse上工作 [英] Java scanner not working on eclipse

查看:305
本文介绍了Java扫描器不能在eclipse上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序编译并运行,但不允许我输入任何值。该程序只是结束而不让我输入任何东西。为什么?

The program compiles and runs, but it is not allowing me to input any value. The program just ends without letting me input anything. Why?

package prac;

import java.util.Scanner;

    public class prac {

        public static void main(String args[]) {

            Scanner input = new Scanner(System. in );
            int number;
            System.out.println("Input number: ");
            number = input.nextInt();
            System.out.println(number);


        }

    }


推荐答案

看起来你错过了扫描仪的简短说明

Looks like you are missing a close statement for Scanner

尝试:

number = input.nextInt();
in.close();

这篇关于Java扫描器不能在eclipse上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆