码迷,mamicode.com
首页 > 其他好文 > 详细

查找“asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd” 该字符串中有多少个af

时间:2016-06-02 21:59:54      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

package lovo.bean; import java.util.Scanner; public class Java { @param args public static void main(String[] args) { // 1、查找“asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd” 该字符串中有多少个af 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);

查找“asdfjvjadsffvaadfkfasaffdsasdffadsafafsafdadsfaafd” 该字符串中有多少个af

标签:

原文地址:http://www.cnblogs.com/RunawayMama/p/5554370.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!