私はプログラミングにかなり慣れていないので、返信を厳しくしてもかまいません。何でも役に立ちます。基本的に、メソッド LineCount() を呼び出そうとしていますが、コマンド プロンプトをコンパイルしようとすると、.class が String[A] で期待されていると不平を言います (8 行目)
* いつもお世話になっております!私のコードは今動作します! 私は本当にすべての入力に感謝します
import java.util.Scanner;
import java.io.*;
public class FileCount{
public static void main(String[] args) throws IOException{
String[] in = new Scanner(new File(args[0]));
System.out.println(lineCount(String[] in);
}
public static void lineCount(String[] A){
// check number of command line arguments
if(args.length != 1){
System.err.println("Usage: LineCount file");
System.exit(1);
}
// count lines, words, and chars in file
int lineCount = 0;
while( in.hasNextLine() ){
in.nextLine();
lineCount++;
}
in.close();
System.out.println( args[0]+" contains "+lineCount+" lines" );
}
}