我有一个与变量“totalFloat”有关的私人访问错误。但是,我一直在引用和使用同一个类的方法,没有这个问题。
在这种情况下,有没有一种通用的方法来解决私人访问错误?
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();
}
}