Given an initialized String variable outfile, write a statement that declares a PrintWriter reference variable named output and initializes it to a reference to a newly created PrintWriter object associated with a file whose name is given by outfile. (Do not concern yourself with any possible exceptions here–assume they are handled elsewhere.)

LANGUAGE: JAVA

CHALLENGE:

Given an initialized String variable outfile, write a statement that declares a PrintWriter reference variable named output and initializes it to a reference to a newly created PrintWriter object associated with a file whose name is given by outfile. (Do not concern yourself with any possible exceptions here–assume they are handled elsewhere.)

SOLUTION:

PrintWriter output = new PrintWriter(outfile);