(java.util.Scannerに)私はエラーが何であるかを把握することはできません1980年から2006年にハリケーンについての情報を含むファイルを読み込む必要はあり割り当てを持っています。私は次のようなコードセクションを持っています:java.util.InputMismatchException;ヌル
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class Hurricanes2
{
public static void main(String[] args)throws IOException
{
//declare and initialize variables
int arrayLength = 59;
int [] year = new int[arrayLength];
String [] month = new String[arrayLength];
File fileName = new File("hurcdata2.txt");
Scanner inFile = new Scanner(fileName);
//INPUT - read data in from the file
int index = 0;
while (inFile.hasNext()) {
year[index] = inFile.nextInt();
month[index] = inFile.next();
}
inFile.close();
これはちょうど最初の部分です。しかし、whileステートメントのセクションでは、year[index] = inFile.nextInt()
にエラーがあります。私はエラーが何を意味するか分からず、助けが必要です。前もって感謝します。
が、私はこれとそれを試してみましたエラーを変更しませんでした。しかし、助けてくれてありがとう。 –