Whenever I type the scanner as a "nested line" it will warn me that [Resource leak: 'unassigned closeable value' is never closed] and advised me to add @SuppressWarnings("resource")
at top of it.
Is it right to just add the @SuppressWarnings("resource")
as it advised or there is another way which is more preferable?
public static void main(String [] args){
String name = new Scanner(System.in).nextLine();
System.out.printf("My name is %s", name);
}