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?
10 ответов
+ 1
Please post the code, so we can have a view on it.
+ 1
myVar.close();
This closes your input stream and should be your solution
+ 1
it did not work. It said "Error: Could not locate or load the main class classInput"
0
import java.util.Scanner;
class MyClass {
public static void main(String[ ] args) {
Scanner myVar = new Scanner(System.in);
System.out.println(myVar.nextLine());
}
}
0
it didn't work. can you give me the complete code? with the "myVar.close(); " ?
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();
}
}
0
eclips
0
it doesn't ask for any input. It just say that is an error.
0
I tested the code that you gave to me and worked on the code playground. but not on eclipse
0
your error message says it tries to find a class "classInput" where do you need it and where do you declare it?