0

I'm having some trouble with the input code.

I copied the code that SoloLearn gives and on my Eclipse say "Resource leak: 'myVar' is never closed" Can someone help me?

3rd Jan 2017, 7:25 PM
Davi Sodre
Davi Sodre - avatar
10 Respuestas
+ 1
Please post the code, so we can have a view on it.
3rd Jan 2017, 8:03 PM
Andreas K
Andreas K - avatar
+ 1
myVar.close(); This closes your input stream and should be your solution
3rd Jan 2017, 8:10 PM
Andreas K
Andreas K - avatar
+ 1
it did not work. It said "Error: Could not locate or load the main class classInput"
3rd Jan 2017, 8:37 PM
Davi Sodre
Davi Sodre - avatar
0
import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); System.out.println(myVar.nextLine()); } }
3rd Jan 2017, 8:07 PM
Davi Sodre
Davi Sodre - avatar
0
it didn't work. can you give me the complete code? with the "myVar.close(); " ?
3rd Jan 2017, 8:23 PM
Davi Sodre
Davi Sodre - avatar
0
import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); System.out.println(myVar.nextLine()); myVar.close(); } }
3rd Jan 2017, 8:27 PM
Andreas K
Andreas K - avatar
0
eclips
3rd Jan 2017, 8:42 PM
Davi Sodre
Davi Sodre - avatar
0
it doesn't ask for any input. It just say that is an error.
3rd Jan 2017, 8:49 PM
Davi Sodre
Davi Sodre - avatar
0
I tested the code that you gave to me and worked on the code playground. but not on eclipse
3rd Jan 2017, 8:56 PM
Davi Sodre
Davi Sodre - avatar
0
your error message says it tries to find a class "classInput" where do you need it and where do you declare it?
3rd Jan 2017, 8:57 PM
Andreas K
Andreas K - avatar