I want to write a method like this: public void print(Scanner scan)
,
and I want to use the try with resource to enclose scan in order to have it closed automatically.
However, I can't write this: try(scan)
How come I am able to write: try(Scan scan = new Scanner())
, but I can't just put in the scan variable from my method parameter in order to get the benefit from try with resource?