Einzelnen Beitrag anzeigen
Alt 23.11.2004, 08:50   #2
jak
Inventar
 
Registriert seit: 13.06.2001
Beiträge: 1.830


Standard

Du kannst z.B. folgendes machen:
Code:
String s="123456789abcd";
char[]c =s.toCharArray();
for (int i=0; i<c.length; i++){
 if ((c[i]=='3')||(c[i]=='9')){
  System.out.println("Fehler");
  exit; //sollte die Schleife beenden (wenns stimmt)
 }
}
oder kürzer:
[code]
if ((s.indexOf('3')!=-1)||(s.indexOf('9')!=-1)){
system.out.println("Fehler");
}
beides nicht getestet, sollte aber funktionieren (vor allem das zweite).
Das zweite hättest du auch mühelos in der Java Doku gefunden.

Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona)
Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing.
\"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra)
jak ist offline   Mit Zitat antworten