public class VariantTest{
public static int staticVar = 0;
public int instanceVar = 0;
public VarianTest(){
staticVar++;
instanceVar++;
}
}
java数组转字符串
char data[] = {'a','b','c'};
String str = new String(data);
String str = "abc";
String d = "abc".substring(1,2);
字符串缓冲区,stringbuffer
字符串生成器 stringbuilder
str.chatAt('index')
str.compareTo(str);按字典顺序比较两个字符串
compareToIgnoreCase(String str) 忽略大小写来字典顺序比较
str.concat(str)
boolean str.contanins(charsequences s)
str.endWith(str)
str.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
str.indexOf(char ch);
str.isEmpty() length()为0,返回true
str.length()
str.replace()
str.replaceAll()
上面两个都是相同的,替换全部
str.replaceFirst()
str.toCharArray()
StringBuffer 同 Stringbuilder的方法,区分就是是否同步
stringbuffer.append()
stringbuffer.capacity()
sb.charAt()
sb.delete()
sb.deleteCharAt()
sb.insert(index,char)
sb.length()
sb.replace(start,end,str)
sb.reverse()
sb.getChars()
sb.indexOf()
stringBuilder 是线程不安全的,要线程安全使用stringbuffer
网友评论