PrintWriter: passing File reference vs String
What is the difference between passing a PrintWriter a reference to a File object and passing it the String filename? If you just want to use the format method to write to a file, both arguments seem to do the same thing, but my instructor always passes a File object instead of just a String. Is that way better somehow?
Re: PrintWriter: passing File reference vs String
To see the differences between the various constructors, the place to start is their API documentation.
It is a fair bet that the library writers will not include multiple constructors for any class unless there *is* some reasonably common occasion when you would prefer one to another. (This applies to all eight constructors, not just the two you mention - each of them might be preferable depending on circumstances.) Your choice will not lie in the fact want to use the printf() methods: after all, these methods do the same thing however the PrintWriter instance is constructed. One reason why a person might prefer the File constructor over the String one is if they intend using the File reference for other purposes like testing whether the file exists and is writable.