String类的常用方法

来源:互联网 发布:mac如何用搜狗输入法 编辑:程序博客网 时间:2024/05/17 02:41
public class StringDeom_1 {public static void main(String []args ){String str1="abc123abc123abc123";String str2="a";String str3="b";String str4="a1";System.out.println(str1.charAt(1));System.out.println(str2.compareTo(str3));System.out.println(str2.contains(str3));System.out.println(str1.endsWith("b"));System.out.println(str1.startsWith("a"));System.out.println(str1.indexOf('1'));System.out.println(str1.indexOf("b"));System.out.println(str1.lastIndexOf('1'));System.out.println(str1.length());System.out.println(str1.replace("a", "b"));System.out.println(str1.substring(0,4));}}

原创粉丝点击