/**
* Created by 王逸群 on 2017/5/5.
*/
public class Main {
public static void main(String[] args) {
String string = "Wang.yi.qun";
//charAt(int index)Returns the char value at the specified index
System.out.println(string.charAt(0));
System.out.println(string.codePointAt(1));
System.out.println(string.codePointBefore(1));
System.out.println(string.codePointCount(0,2));
// 注意返回值是 int
System.out.println(string.compareTo("Wang.yi.qun"));
System.out.println(string.compareToIgnoreCase("WANG YI QUN"));
//concat
System.out.println(string.concat(" how are you?"));
System.out.println(string.contains("yi"));
System.out.println(string.contentEquals("wang"));
//copyValueOf ?
char []ch = new char[2];
ch[0] = '1';
ch[1] = '2';
System.out.println(String.copyValueOf(ch,0,2));
System.out.println(string.endsWith("qun"));
string.equals("Wa");
string.equalsIgnoreCase("2");
System.out.println(string.getBytes());
string.toLowerCase();
string.toUpperCase();
string.trim();
System.out.println(string);
System.out.println(string.substring(1,2));
System.out.println(string.split(" "));
//但是 用这个里面的鬼东西一定要注意了。。。里面是正则表达式
//StringTokenizer 用这个吧
System.out.println(string.replaceAll(".","2"));
}
}
Java 中字符串的一些总结
最新推荐文章于 2018-05-04 13:50:00 发布