For the simplicity of writing a lot and also boring you guys I just have a question and if you guys can give me another example as well using maybe something simpler.
Here is the code
PrinterWriter w = new PrinterWriter(new FileWriter("test.txt"));
ok so the above works perfectly fine but so does this
FileWriter fw = new FileWriter("test.txt");
So does this work
PrintWriter w = PrintWriter(new File("test.text");
Ok so now all of these work but I am more concerned on why does the one in italics work.
I have read some of the documentation and have noticed that it takes a Writer
as the constructor argument, which FileWriter
is an extension of.
But if that is true then why does this not work (or maybe it does)
FileWriter fw = FileWriter(new PrintWriter("test.txt));
I have not yet confirmed if this works but I do not see what this would do anyways ( the others make sense ) but can anyone just explain even the slightest bit of information?