import java.util.Scanner;
public class Main{
public static int char_length(String s, String c){
int count = 0;
for(int i=0; i<s.length(); i++){
if(s.substring(i,i+1).equalsIgnoreCase(c)){
count++;
}
}
return count;
}
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String s = in.nextLine();
String c = in.nextLine();
System.out.println(char_length(s,c));
}
}
実施例で使用される主な方法がある:
サブストリング(beginIndexパラメータINT、INT endIndexの):
これは、文字列の部分文字列を取るための方法であって、beginIndexパラメータとendIndexのピッチは1に設定されている場合、のみ取ることができます文字。
equalsIgnoreCase(文字列anotherString) :
これは、等号である()メソッドは無視の文字の場合を比較します。
只要每天积累,一定会有收获!