テキスト ブロックの各行から最長の単語のリストを取得しようとしています。processing.classにあるメインから印刷する情報を取得できません。情報は Tools.class で処理されます。また、関連する Counters.class もありますが、これは不変です。
ただし、次The value of the local variable longestWords is not usedの警告が表示されます。私のカウンター コードで、宣言している行でlongestWords =h;. これはなぜですか、どうすれば修正できますか?
これは私のコードです:
(処理)
longestWords = stat.getLongestWords();
    for(i = 0; i < longestWords.size(); i++){
        System.out.print(longestWords.get(i));
    }
スローされたエラー: スレッド「メイン」の例外 java.lang.NullPointerException at deol5210_a1.Processing.main(Processing.java:66)
for(i = 0; i < longestWords.size(); i++){ (ツール)
}else {
            currentWord = lineScanner.next();
            if(currentWord.contains("$")){
                currentWord.replace("$", "");
                moneySpent += Double.parseDouble(currentWord.replace("$", ""));
            }else if (currentWord.length() > lineLongestWord.length()){
                lineLongestWord = currentWord;
            }
            if(currentWord.length() > longestWord.length()){
                longestWord = currentWord;
                lineLongestWord = currentWord;
                wordCount++;
            } else {
                wordCount++;
            }
(カウンター)
    public ArrayList<String> getLongestWords(){
    return longestWords;
}
public Counters(int a, double b, int c, int d, double e, double f, String g, ArrayList<String> h){
    lineCount = a;
    avgWordCount = b;
    wordCount = c;
    purchaseCount = d;
    moneySpent = e;
    avgSpent = f;
    longestWord = g;
    ArrayList<String> longestWords = h;
}