我想編譯一個程序,但是我不斷收到一些我以前從未見過的錯誤。這是我的計劃:獲取錯誤,但我不確定它們是什麼意思
import java.util.Scanner;
import java.io.FileReader;
import java.io.*;
public class Project1
{
public static void main (String [] args) throws FileNotFoundException
{
Scanner inFile = new Scanner(new FileReader("artists.txt")); //read from file
Scanner console new Scanner(System.in); //read from user input
int sum = 0; //sum of revenue
String artist; //user input
int revenue = 0; //store yearly revenue
System.out.println("Please enter the name of a band/artist: ");
artist = console.next();
String[] tokens = artist.split(" ");
while(inFile.hasNext())
{
if (tokens == inFile.hasNext())
{
if (inFile.Next == (2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012));
{
if (inFile.hasNext())
{
revenue = inFile.nextInt();
sum += revenue;
System.out.print("sum");
}
}
}
}
inFile.close();
我得到的錯誤如下:
Error: Syntax error, insert ";" to complete LocalVariableDeclarationStatement [Line 13]
Error: Syntax error on token "==", Name expected after this token [Line 30]
如果有人碰巧看到任何其他錯誤,隨意點出來。謝謝。
如果您正在學習Java,我認爲您應該從更簡單的Java示例開始。你的代碼有基本的語法錯誤... –