Breathe life into this code by fixing all those pesky compile-time errors and make it work! Use try-with-resources to solve this problem.
Try with resources
Can be fixed
Report a typo
Sample Input 1:
JavaSample Output 1:
I'm learning JavaWrite a program in Java 17
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
public static String main(String[] args) {
String language;
BufferedReader buffReader;
try {
BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));
language = buffReader.readLine();
System.out.println("I'm learning " + language);
} catch (IOException e) {
e.printStackTrace();
} finally {
buffReader.close();
}
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.