1
這是我的代碼,旨在讀取具有多行的文件,每行包含字符串和浮點數並打印出每行。我一直得到一個錯誤無法找到方法split()和loadStrings()的符號。 我在做什麼錯?處理找不到符號錯誤java
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.io.File;
import java.util.SplittableRandom;
public class EmployeePay {
public static void main(String[] args) throws FileNotFoundException {
if (args.length != 1) {
final String msg = "Usage: EmployeePay name_of_input file";
System.err.println(msg);
throw new IllegalArgumentException(msg);
}
final String inputFileName = args[0];
final File input = new File (inputFileName);
final Scanner scanner = new Scanner(input);
String line = " ";
String Identification = " ";
float WorkTime;
float MoneyPerHour;
int TotalDeductions= 0;
String[] lines, info;
float[] numberInfo;
lines = loadStrings(scanner);
info = new String [lines.length];
numberInfo = new float [lines.length];
String [] tokens;
for (int i =0; i < lines.length; i++){
tokens = split(lines[i]," ");
info [i] = tokens[0];
numberInfo[i]= Float.parseFloat(tokens[1]);
System.out.println(info[i]+" "+numberInfo[i]);
}
「split」定義在哪裏?你的'EmployeePay'類沒有這樣的方法 – MadProgrammer