集册 Java实例教程 运动字符串法

运动字符串法

欢马劈雪     最近更新时间:2020-01-02 10:19:05

454
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建一个字符串实例
//时 代 J     a    v  a - nowjava.com 提 供

public class Main {


    public static void main(String[] arguments) {

        String str = " this is a test. this is a test. this is a test?";


        System.out.println("The string is: " + str);

        System.out.println("Length of this string: " + str.length());

        System.out.println("The character at position 6: " + str.charAt(6));

        System.out.println("The substring from 26 to 32: " + str.substring(26, 32));

        System.out.println("The index of the first 'a': " + str.indexOf('a'));

        System.out.println("The index of the beginning of the " + 
展开阅读全文