String方法的应用:

package com.tets;

public class Demo2 {
       public static void main(String[] args){
           String str="Hello world";
           String str2="hello world";
             int len=str.length();
           boolean b=str.startsWith("H");
           boolean c=str2.contains("Hello");
           boolean d=str2.endsWith("d");
          System.out.println("字符串的长度是"+len);

          System.out.println(b+c+d);
       }
}

猜你喜欢

转载自www.cnblogs.com/yang-1yang/p/10088540.html