Не могу найти ошыбку, ПОМОГИТЕ
package com.javarush.task.task22.task2207;
import java.io.*;
import java.util.*;
/*
Обращенные слова
*/
public class Solution {
public static List<Pair> result = new LinkedList<>();
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
String fname = sc.nextLine();
Scanner fis = new Scanner(new File(fname));
String[] mas;
ArrayList<String> word_array = new ArrayList<>();
while (fis.hasNext()) {
mas = fis.nextLine().split(" ");
for (String check : mas) {
word_array.add(check);
}
}
StringBuilder[] strm= new StringBuilder[word_array.size()];
for (int i = 0; i < word_array.size(); i++) {
strm[i] = new StringBuilder(word_array.get(i));
}
for (int i = 0; i < strm.length; i++) {
for (int j = i; j < strm.length; j++) {
if (strm[i].equals(strm[j].reverse())) {
boolean b = false;
for (Pair p : result) {
if (p.first.equals(strm[i]) || p.first.equals(strm[i]))
b = true;
}
if (b) {
result.add(new Pair(strm[i].toString(), strm[j].reverse().toString()));
}
}
}
}
}
public static class Pair {
String first;
String second;
public Pair() {
}
public Pair(String first, String second) {
this.first = first;
this.second = second;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pair pair = (Pair) o;
if (first != null ? !first.equals(pair.first) : pair.first != null) return false;
return second != null ? second.equals(pair.second) : pair.second == null;
}
@Override
public int hashCode() {
int result = first != null ? first.hashCode() : 0;
result = 31 * result + (second != null ? second.hashCode() : 0);
return result;
}
@Override
public String toString() {
return first == null && second == null ? "" :
first == null ? second :
second == null ? first :
first.compareTo(second) < 0 ? first + " " + second : second + " " + first;
}
}
}