找不到符号"找不到符号"

时间:2018-01-17 15:25:58

标签: java

我遇到了编译代码的问题。我设法解决了所有出现的编译错误,除了少数几个找不到的符号都围绕着我收到输入的点。对于我的生活,我无法找到导致他们的原因。我意识到我可能会忽视某些东西,但我现在还不知道那是什么。

import java.util.Scanner;
import java.io.*;

public class Tester{
    public static void main(String[] args){
    Scanner input=new Scanner(new File(args[0]));

    while(input.hasNextLine()){
     char posit = input.nextChar();//Finds first character
     String compar = Character.toString(posit);
     if(compar.equals("#")){//If using manager symbol
        String firstN = input.nextString();
        String lastN = input.nextString();
        double var1 = input.nextDouble();

        Employee.Manager(firstN, lastN, var1);

     }//End if manager statement

     else if(compar.equals("*")){//If using hourly symbol
        String firstN = input.nextString();
        String lastN = input.nextString();
        double var1 = input.nextDouble();
        double var2 = input.nextDouble();

        Employee.HourlyWorker(firstN, lastN, var1, var2);

     }//End if hourly statement       
   }//End while loop
  }//End main method
}//End class

以下是我的错误:

Line 14:  error: cannot find symbol 
     char posit = input.nextChar();//Finds first character                   
symbol:   method nextChar() 
location: variable input of type Scanner 

Line 17:  error: cannot find symbol 
        String firstN = input.nextString();  
symbol:   method nextString() 
location: variable input of type Scanner 

Line 18:  error: cannot find symbol 
        String lastN = input.nextString();                                 
symbol:   method nextString() 
location: variable input of type Scanner 

Line 26:  error: cannot find symbol 
        String firstN = input.nextString();                                 
symbol:   method nextString() 
location: variable input of type Scanner 

Line 27:  error: cannot find symbol 
        String lastN = input.nextString();                                 
symbol:   method nextString() 
location: variable input of type Scanner 
5 errors 

1 个答案:

答案 0 :(得分:0)

你需要使用' input.next()。charAt(0);'而不是input.nextChar();

  

char posit = input.next()。charAt(0);