find duplicates with two loadString arrays.
in
Programming Questions
•
1 year ago
hi, I am trying to find the duplicates in two String arrays that each got its contents by loading two different textfiles into them respectively (with loadString). So I have stringArray_1 with the contents of textFile_1 and stringArray_2 with contents of textFile_2.
Now I am trying to find duplicates in these two arrays but it seems that although stringArray_1[0] and stringArray_2[0] have the same string in them, they are not recognized as equal. This only happens when I load the strings with loadString but not when I fill the string array "manually"..
I also tried to use the Hashset.contains method but I am wondering if it is possible to just compare the two arrays when they are filled with loadString. Is it not a String anymore when using loadString? it seems it gets converted to an object instead?
- String[] stringArray_1 = loadStrings("testfile01.txt");
- String[] stringArray_2 = loadStrings("testfile02.txt");
- if( stringArray_1[0] == stringArray_2[0] ){
- println("True");
- } else {
- println("not True");
- }
1