题解 | #计算某字符出现次数#
计算某字符出现次数
http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1
import java.io.BufferedReader; import java.io.InputStreamReader;
public class Main { public static void main(String[] args) throws Exception{ String word="",word1 = ""; BufferedReader buf= new BufferedReader(new InputStreamReader(System.in)); word = buf.readLine().toLowerCase(); word1 = buf.readLine().toLowerCase(); int index = 0; for(int i= 0;i<word.length();i++){ if (word.charAt(i)==word1.charAt(0)) index++; } System.out.println(index); } }