package com.te.jdkapi;
import java.util.Arrays;
public class StringDemo {
public static void main(String[] args) {
String name = new String("caihengaiaikjkj");
String name2 = new String("CAIHENG");
System.out.println(name.equalsIgnoreCase(name2));
System.out.println(name.length());
System.out.println(name.substring(3));//截取从3以后的字符串
System.out.println(name.substring(1,3));//截取从1到3的字符串
System.out.println(name.charAt(1)); // 获取索引为1的字符
System.out.println(name.indexOf("ai"));// 获取字符串第一次出现的下表
System.out.println(name.lastIndexOf("ai"));// 从最后开始最开始出现的下表
System.out.println(name.replace("ai","ok"));//替换
String[] arr = name.split("a"); // 以什么分割字符串
System.out.println(Arrays.toString(arr));
}
}
标签:string,ai,System,name,学习,String,println,out
From: https://www.cnblogs.com/ch2020/p/16854118.html