Fifth weekly summary reports & test course (three)

Application third experiment String class

Purpose

Master the use of class String class;
learn to use JDK help documentation;

Content Experiments

1. Known string: "this is a test of java" required to do the following requirements :( source code, the results screenshot).

统计该字符串中字母s出现的次数。
统计该字符串中子串“is”出现的次数。
统计该字符串中单词“is”出现的次数。
实现该字符串的倒序输出。

2. Write a program, using the following algorithm to encrypt or decrypt the English string input by the user. It requires source code, the results screenshot.

3. Given the string "ddejidsEFALDFfnef2357 3ed". The output string in the number of capital letters, lowercase letters count, the number of non-English letters.

1, the source code:

public class 第一小题 {
     public static void main(String[] args) {
         String str="This is a test of java";
         int num1=0;
         for(int i=0;i<str.length();i++) {
             if(str.charAt(i)=='s')
                 num1++;
        }
         System.out.println("字母s出现的次数:"+num1);
     }
}

Screenshot results:

Design ideas:
have the book.

Guess you like

Origin www.cnblogs.com/qiuf99999/p/11593215.html