package lovo.Linyoujia;
import java.util.Scanner;
public class Java {
@param args
public static void main(String[] args) {
TODO Auto-generated method stub
String bs = "asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd";
int count = 0;
char[] charArray = bs.toCharArray();
for (int i = 0; i < bs.length() - 1; i++) {
if (charArray[i] == ‘a‘ && charArray[i + 1] == ‘f‘) {
count++;
}
}
System.out.println(count);
时间: 2024-10-08 08:50:47