I found a try with resources example that doesn't compile when I try to set the value of the reference scan to null
try(Scanner scan = new Scanner(System.in)) {
String s = scan.nextLine();
System.out.println(s);
scan = null;
}
I ask what's the rule behind this compilation error , I did some search on the net but i didn't find a rule that explain it Thanks for any explanation : =)