-1

this is a very basic question, but can't seem to get the right answer on myProgrammingLab.

NOT A SCREENSHOT

Declare a local variable output that is suitable for referring to an object that provides methods for writing to a text file.

Master Yi
  • 13
  • 5

1 Answers1

1

You can declare a PrintWriter, which provides methods for writing to text files:

PrintWriter output = new PrintWriter("textfile.txt");

To use it:

output.println("hello");
output.close();

You'll need a try/catch block for an IOException.

Santiago Benoit
  • 994
  • 1
  • 8
  • 22