1
たとえば、私が比較する必要があるファイルは、このようなもので、すべてタブで区切られています。私は2人の異なる人の時と得点を比較する必要があります。このファイルは、最初の数字は秒単位、2番目はスコアです。これまで文字列配列の数値を比較するにはどうすればよいですか?
ジョン・スミス10 30
ピーター・グリーン99 85
私のコードは:
はFile testResults= new File("TestResults.txt");
Scanner inputFile= new Scanner(testResults);
String[] testResultArr=new String[4];
int c=0,minTime=0,minGrade=0,maxGrade=0,avgGrade=0,sum=0,time=0,scores=0;
while(inputFile.hasNext())
{
String line= inputFile.nextLine();
testResultArr= line.split("\t");
time= Integer.parseInt(testResultArr[2]);
scores= Integer.parseInt(testResultArr[3]);
minTime=time;
if(minTime<time)
minTime=time;
}
System.out.println("Lowest Time: "+minTime);
出力:10
あなたの比較は後方ですか? –