1
我有一個與變量「totalFloat」有關的私人訪問錯誤。不過,我一直在引用和使用同一個類的方法,而沒有這個問題。私人訪問? Java
在這種情況下是否有避開私人訪問錯誤的一般方法?
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();
}
}
totalFloat非靜態 – 2012-07-26 08:14:17
totalFloat是如何聲明的? – 2012-07-26 08:14:29
cd是什麼?它是ChangeDrawer類型的對象嗎? – Leon 2012-07-26 08:16:00