看书总结的一些回顾。
//String类
// char a[]={'g','o','o'.'d'};String s=new String(a);等价于String s=new String("good");
//加号连接字符串(与其他类型连接会将其他部分也转换为字符串)
//length(String)获取字符串长度
//indexOf(String)字符或字符串在一个字符串中首次出现的索引位置,lastIndexOf()最后一次出现的位置
//charAt(int)获取指定位置的字符
//substring(int)或substring(int,int)对字符串进行截取
//String trim(void)返回字符串副本(忽略首尾的空格)
//String replace(char1,char2),将字符串的char1替换为char2,得到了一个副本
//Boolean startsWith(String) Boolean endsWith(String)分别判断字符串是否以指定内容开始或结束
//字符串比较不能用“==”,它比较的是内存地址,应当使用str1.equals(str2),这个是区分大小写的,不区分的是equalsIgnoreCase()
//按照字典序比较两个字符串str1.compareTo(str2),str1在str2之前(字典序较小)则返回-1,反之为1,字符串相等为0
//toLowerCase()将字符串转换为小写,toUpperCase()为大写,得到副本
//字符串分割:String[] str.split(String) 以及 split(String,int)加上了分割次数
//静态方法格式化字符串format(String format,Object);如String s=String.format("%te",date);
//格式化年月日,格式化时间等参考转换符表
//常规格式化类型,格式化为字符串,格式化为十进制等等,参考表
//正则表达式
//StringBuilder类,可变的字符序列,使用它是因为一般的String类型在使用加号等操作会在内存中创建新对象,效率低
//StringBuilder:append() insert(int,String) delete(int start.int end) 字符串生成器对象以toString()来处理输出