我已經使用Java在NetBeans IDE中編寫了一個簡單的程序。在今天上午對主要方法進行了一些更改之後,當我運行該程序時,控制檯不會打印任何內容。我只是想讓它達到startMenus(sc)。編輯:現在我已經把幾的System.out.println(),它沒有達到「Blah2」這是我的第一個循環後,右......NetBeans不會打印到控制檯JAVA
public class Calculator {
public static int[] NUMBERS; //global value for the array
public static void main(String[] args) throws FileNotFoundException {
File file = new File("data.txt");
Scanner sc = new Scanner(file);
System.out.println("Blah1");
int counter = 0;
while (sc.hasNextInt()) {
counter = counter++;
}
System.out.println("Blah2");
int lenth = counter;
NUMBERS = new int[lenth];
System.out.println("Blah3");
sc.close();
File file2 = new File("data.txt");
Scanner sc2 = new Scanner(file2);
System.out.println("Blah4");
int i = 0;
while (sc2.hasNextInt()) {
NUMBERS[i] = sc2.nextInt();
++i;
}
System.out.println("Blah5");
sc2.close();
System.out.println("Welcome to Calculation Program!\n");
startMenus(sc);
}
}
是否有例外?注意到主要方法拋出一個異常,但是誰或什麼正在處理該異常? – Mechkov 2013-03-11 19:46:38
你確定這不是因爲它只是沒有完成循環之前,你認爲它沒有做到這一點? – 11684 2013-03-11 19:46:50
在程序啓動時嘗試System.out,以確保:) – 2013-03-11 19:47:39