Hi
I have a simple code snippet here that writes to a file called Student.txt :
import java.io.*;
import java.util.*;
public class Streams {
public static void main(String[] args) {
String studentFirstName = "Bob ";
String studentLastName = " Smith ";
String finalGrade = "A";
try {
PrintWriter out = new PrintWriter(new FileOutputStream("Student.txt"));
out.print(studentFirstName);
out.println(studentLastName);
out.print(finalGrade);
}
catch (IOException e) {
System.out.println(e);
}
finally {
out.close();
}
}
}
But I get an error for this bit called 'out cannot be resolved.' ;
finally {
out.close();
}
Can anyone explain why?