public class MyJava {
public static void main(String[] args) {
String srt = "woyaoxuejava,xihuanjava,aijava,javajavawozuiai" ;
char[] ch=srt.toCharArray();
int x = 0;
for (int i = 0; i < ch.length; i++) {
String a = ch[i]+"";
if (a == "j") {
x++;
break;
} else {
continue;
}
}
System.out.println(x);
}
}
|
|