我正在开发一个为三个不同的人订购工作的程序,所以我使用了队列,因为工作需要先进先出。这些作业是存储三个不同字符串的数组。这是我目前拥有的相关代码。
Queue<String[]> MMT1Jobs = new LinkedList<String[]>();
Queue<String[]> MMT2Jobs = new LinkedList<String[]>();
Queue<String[]> MMT3Jobs = new LinkedList<String[]>();
//job array layout should look like this [registration number][grid reference][who is assign to the job]
String[] MMT1CurrentJob = new String[3];
String[] MMT2CurrentJob = new String[3];
String[] MMT3CurrentJob = new String[3];
String[] MMT1LastJob = new String[3];
String[] MMT2LastJob = new String[3];
String[] MMT3LastJob = new String[3];
String[] justScanned = new String[3];
//check if there is any Jobs open
File jobsOpenFile = new File("JOBS-OPEN.txt");
if(jobsOpenFile.exists())
{
//File exists
Scanner jobsFile = new Scanner(jobsOpenFile);
while(jobsFile.hasNext == true)
{
justScanned[1] = jobsFile.next();//registration number
justScanned[2] = jobsFile.next();//grid reference
justScanned[3] = jobsFile.nextLine();//who is assigned and end of line
//assign who get what jobs
if(justScanned[3].equals("1"))
{
MMt1Jobs.add(justScanned[]);//error here
}
else if(justScanned[3].equals("2"))
{
MMt2Jobs.add(justScanned[]);//error here
}
else
{
MMt3Jobs.add(justScanned[]);//error here
}
}
}
我目前在我标记的行上收到“错误:'.class'预期”。对不起,如果这是一个简单的修复,但我是 java 新手。提前致谢。