Hi.
Stimmt, deine Lösung ist eleganter. Allerdings waren da die beiden Probleme von oben noch nicht weg, aber das hab ich noch gemacht. Danke!
(Hier nochmal der aktuelle Code
Gruß, Jan.Code:public class Array { public static void main(String args[]) { String s[] = new String[10]; String name = "a"; s[0] = "x"; s[1] = "g"; s[2] = "e"; s[3] = "b"; s[4] = "s"; s[5] = "i"; s[6] = "k"; s[7] = "r"; s[8] = "a"; s[9] = "p"; byte index = -1; for(byte i = 0; i < (s.length - 1); i++) { if(s[i] != null && s[i].equals(name) == true) { index = i; break; } } System.out.println(index); } }







Zitieren

Lesezeichen