public class StringUse {
public static void main(String[] args) {
int count = 0;
String s=new String("hello!");
String b="hello";
String c="abcde";
String a=new String();
a="HELLO!";
//StringBUffer的charAt
StringBuffer sb=new StringBuffer("aibicimimi");
for(int i=0;i<sb.length();i++){
if(sb.charAt(i)==‘i‘){
count++;
}else{
continue;
}
}
System.out.println(count);
//delete
System.out.println(sb.delete(0, 2).toString());
//inser
System.out.println(sb.insert(2, "xixi"));
//charAt
/*System.out.println(s.charAt(4));
//codePointAt
System.out.println(s.codePointAt(4));
//codePointBefore
System.out.println(s.codePointBefore(4));
//codePointCount
System.out.println(s.codePointCount(2, 5));*/
//compareTo
/*System.out.println(s.compareTo(c));
//compareToIgnoreCase
System.out.println(s.compareToIgnoreCase(a));
//concat
System.out.println(s.concat(a));
//替代上面
String string="s:"+s+"a:"+a;
System.out.println(string);
//copyValueOf
char d[]=new char[]{‘h‘,‘m‘,‘n‘};
System.out.println(s.copyValueOf(d));
System.out.println(s);
//s.endsWith
System.out.println(s.endsWith("l"));
System.out.println(s.equalsIgnoreCase(a));
//getBytes
byte[] e=s.getBytes();
System.out.println(Arrays.toString(e));
//indexOf
System.out.println(s.indexOf("l"));*/
//lastIndexOf
/* System.out.println(s.lastIndexOf("l"));
//replace
System.out.println(s.replace(‘l‘, ‘o‘));
//split
String string[]=s.split("h");
System.out.println(Arrays.toString(string));*/
//substring
/*System.out.println(s.substring(1));
//toUpperCase
System.out.println(s.toUpperCase());
System.out.println(s.valueOf(2));*/