So I'm trying to create a program that takes input in the form of a First and Last Name and then printing it to a Output.txt file. I'm sort of new to programming, and I think I'm derping on this.
I just keep getting an error on the last part of my program.
PrintInitials.java:21: error: <identifier> expected
} output.close();
^
1 error
Here's my Code
import java.util.Scanner;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.*;
public class PrintInitials
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
String first; // first name
String last; // last name
System.out.print("Enter your first and last name separated by a space: ");
first = stdIn.next();
last = stdIn.next();
File file = new File("Output.txt");
FileWriter writer = new FileWriter(file, true);
PrintWriter output = new PrintWriter(writer);
output.print("Your initials are " + first.charAt(0) + last.charAt(0) + ".");
} output.close();
}