• Register
Log In
0 votes

Problem :

I am just a beginner in java coding.

Recently i got this error and was unable to solve it. Please help me with this.

exception in thread "main" java.lang.illegalstateexception: scanner closed

6.9k points

1 Answer

0 votes

Solution : 

To resolve the issue one must close the scanner and then

call nextInt on it 

calc c = new calc();

int a,b; 

System.out.print("Enter the first number:"); 


and your code will work

36.1k points
edited by

Related questions

0 votes
1 answer 194 views
Problem : I am getting the run time exception in my program while I am reading a file through a Scanner. exception in thread "main" java.util.nosuchelementexception: no line found
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 417 views
Problem : I am trying to pass the values from the servlet to jsp page But when I run the page I am facing below error: Error as below : java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed org.apache.catalina.connector. ... getRequestDispatcher("usertaskpage.jsp"); dd.forward(request, response); But still I got a same error. How can I fix above error?
asked Feb 3 jwilliam 3.9k points
0 votes
1 answer 39 views
Problem : I am trying to run Java Applet and getting bellow error. java.lang.illegalstateexception: failed to create a child event loop
asked Oct 31, 2019 peterlaw 6.9k points
0 votes
1 answer 151 views
Problem : I got following exception from my servlet: java.lang.illegalstateexception: response has already been committed
asked Oct 31, 2019 peterlaw 6.9k points
1 vote
1 answer 17 views
Problem: I am a begginer in java programming language and I have been coding for just some days. To practice my programming I wrote this code in java: public class Main { public static void main(String[] argv){ int 2count, h-l, a/b, } } But It shows me the error message ... , . expected Syntax error on token ",", ;expected at Main.main(Main.java:3) Whats is wrong in my code can anyone help me out?
asked Apr 6 LizzyM 5.7k points