experimental report:
Experiment a well-known string: "this is a test of java" Do the following requirements:
1: count the number of letters in the string s occurs in
Experiment code:
package Java11;
public class TZQD {
public static void main(String[] args) {
String r = "this is a test of java";
int sum = 0;
char[] c = r.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == 's') {
sum++;
}}
System.out.println("S的个数为"+sum);
}
}