java.lang.IllegalStateException:扫描程序已关闭ERROR

时间:2017-01-16 10:21:08

标签: java java.util.scanner illegalstateexception

我只是java编码的初学者。

这只是一个随机程序,处于代码的起始级别。

最近我收到此错误,无法解决。请帮帮我。

# external redirect from actual URL to pretty one
RewriteCond %{REQUEST_URI} !^/blog($|/)$
RewriteCond %{THE_REQUEST} \s/+product/search/\?tag=([^\s&]+) [NC]
RewriteRule ^ /%1/? [R=301,L,NE]

# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_URI} !^/blog($|/)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/designs/ [NC]
RewriteRule ^([^/]+)/?$ product/search/?tag=$1 [L,QSA]

我的计划如下:

Exception in thread "main" Enter the first number:java.lang.IllegalStateException: Scanner closed
    at java.util.Scanner.ensureOpen(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at java.util.Scanner.nextInt(Unknown Source)
    at java.util.Scanner.nextInt(Unknown Source)
    at New.main(New.java:19)

该程序的日期部分完美无缺。这个烂摊子是程序的第二部分。

3 个答案:

答案 0 :(得分:0)

    ...
    d.setdate(hour,min,sec);
    System.out.println(d.display());
    s.close();
    ...

删除声明

    s.close();

答案 1 :(得分:0)

请勿关闭输入流,否则您将无法再次阅读。

 s.close();

显示计算输出:

double d = c.compute(o);
System.out.print("Result:" +d);

答案 2 :(得分:0)

关闭扫描仪,然后点击nextInt

 s.close(); //remove this line

 calc c = new calc();
    int a,b;
    System.out.print("Enter the first number:");
    a=s.nextInt();

请删除s.close();,您的代码将正常工作

相关问题