I have a private access error to do with the variable “totalFloat”. However I have been referencing and using methods from the same class without this problem.
Is there a general way to get around a private access error in this case?
public static void writeHtmlFile() {
double contentsChangeDraw;
String ChangeDrawer = "ChangeFloat.html";
try {
PrintWriter outputStream = new PrintWriter(ChangeDrawer);
contentsChangeDraw=cd.getTotalFloat(totalFloat);
// totalFloat has private access in ChangeDrawer, which means I am
// unable to use the method to calculate the array that needs to be written
outputStream.println(contentsChangeDraw);
outputStream.close();
System.out.println("The contents of the ChangeDrawer have been written to a file");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
I bet
totalFloathas a declaration like this:You can not access it from a static method because it’s a member variable. Make it
to access it (or change your method
writeHtmlFile()to not being static).