Code not working
Hey , my code is : String m = args[0]; int n = Integer.parseInt(m); String[] array = new String[n]; boolean z = false; for (int i = 0 ; i < n ; i++){ array[i] = JOptionPane.showInputDialog("Geben sie einen Namen ein"); } String vergleich = JOptionPane.showInputDialog("Geben sie einen weiteren Namen ein."); for (int i = 0 ; i < n ; i++){ if (vergleich.equals(array[i])){ System.out.println(i); z = true; break; } } if (z == false); System.out.println("Name nicht vorhanden"); But the z does not get set to true whether the equals statement is true or not. When it is true everything else works right , the System.out.println(i) and break is both working right. But the z = true; does not work because the last if statement is triggered in every case , when the equals statement is true or not. Would be nice if someone could help me!