だから私はこれらの行を含むファイルを持っています
155, 490, 297, 490,
-45, 19, 45, 19,
-24, 80,-12,-69, 80,
12,-92, 28,-40,
ファイルを読み取って、重複する要素を含むこれらの行を見つけようとしました。しかし、私のロジックの何かが間違っていて、エラーを見つけることができません。助けはありますか?
コードは次のとおりです。
public static void main(String[] args) throws IOException {
Scanner fileInput = null;
try {
fileInput = new Scanner( new File("array_list.csv"));
String line;
while (fileInput.hasNextLine()) {
line = fileInput.nextLine();
String[] lineArr = line.split(",");
// check for missing values
boolean contains = true;
for(int i=0; i<lineArr.length; i++) {
for(int j=0; j<lineArr.length; j++) {
if(lineArr[i]==lineArr[j]) {
contains = false;
break;
}
}
if(!contains) {
// print the row .....
}
else {
contains = true;
// print some thing ...
}
}
}
} finally {
if (null != fileInput) {
fileInput.close();
}
}
}