There is a task: to find headers in which there are words defined by an array, and to weed out of them headers with words from the second array.
mName - the title in which we are looking for words from the search array. In the second nested loop in 2 if -s, which for some reason I decided to decompose into 2 in order not to get confused, but I still get confused :( The logic lies with the second nosearch array checking
the old
for (int i = 0; i <= search.length - 1; i++) { if (mName.indexOf(search[i]) != -1) { for (int i1 = 0; i1 <= nosearch.length - 1; i1++) { boolean trigger = false; // System.out.println(i1); if (mName.indexOf(nosearch[i1]) != -1) { trigger = false; System.out.println(mName); // break; } else { trigger = true; } if (trigger) { // listVakansy.add(mName); System.out.println(mName); break; } } break; } }
The problem is as follows: the nosearch array contains only the first header that has fallen, all the rest are freely passed to the exhaust.
Added by
I threw it separately and I will not figure it out
public class TestStringSearch { public static void main(String[] args) { String[] search = {"ΡΠ΅ΡΡΠ΅Ρ", "java", "ΡΠΈΡΡΠ΅ΠΌΠ½ΡΠΉ", "cΠΈΡΡΠ΅ΠΌΠ½ΡΠΉ", "ΡΠ΅ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈ", "ΡΠ΅ΡΡΠΈΡΠΎΠ²ΡΠΈΠΊ", "ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ"}; String[] nosearch = {"ΠΈΠ½ΠΆΠ΅Π½Π΅Ρ", "ΠΌΠΈΠΊΡΠΎΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅Ρ", "ΠΌΠΈΠΊΡΠΎΠΊΠΎΠ½ΡΡΠΎΠ»Π»ΡΡ", "1c", "1Π‘", "1c", "c#", "Ρ#"}; String[] str = {"Π²Π΅Π΄ΡΡΠΈΠΉ java ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ", "1c ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ", "ΠΈΠ½ΠΆΠ΅Π½Π΅Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΡ 1Ρ", "ΡΠΏΠ΅ΡΠΈΠ°Π»ΠΈΡΡ ΠΏΠΎ ΡΠΎΠΏΡΠΎΠ²ΠΎΠΆΠ΄Π΅Π½ΠΈΡ ΠΈ ΡΠ΅ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ", "ΡΠ΅ΡΡΠΈΡΠΎΠ²ΡΠΈΠΊ", "ΠΈΠ½ΡΠ΅ΠΆΠ΅Ρ", "Π³Π»ΡΠΊ"}; //ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ ΡΠ»ΠΎΠ² for (int i = 0; i <= str.length - 1; i++) { //ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ ΠΈΡΠΊΠΎΠΌΡΡ
ΡΠ»ΠΎΠ² (search) for (int i1 = 0; i1 <= search.length - 1; i1++) { //ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ Π½Π°ΠΉΠ΄Π΅Π½Π½ΡΡ
ΡΠ»ΠΎΠ² if (str[i].indexOf(search[i1]) != -1) { //ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ ΠΎΡΡΠΈΡΠ°Π΅ΠΌΡΡ
ΡΠ»ΠΎΠ² (nosearch) for (int i2 = 0; i2 <= nosearch.length - 1; i2++) { // Π΅ΡΠ»ΠΈ Π½Π°Ρ
ΠΎΠ΄ΠΈΠΌ ΡΠΎ ΠΏΡΠ΅ΡΡΠ²Π°Π΅ΠΌ if (str[i].indexOf(nosearch[i2]) != -1) { break; } else { System.out.println(str[i]); break; } } } } } } }