All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
By that logic, why only 3, the catch clause can have any number of Exceptions. Also, it should be | and not ||.
But that is not the point of the question. It is getting at the requirement of having at least a catch block or a finally block.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try(Scanner s = new Scanner("")){
System.out.println("Valid try declaration");
}
}
}
A try statement is not same as try-with-resources statement. Both are different. The question is asking about try statement (not try with resources statement).
Problem statement has now been updated to make it clear.