1、length()函数 字符串的长度
<span style="font-size:18px;"> char chars[]={'a','b'.'c'};
String s=new String(chars);
int len=s.length();</span>
2、charAt()截取一个字符 在某个下标的地址
<span style="font-size:18px;"> char ch;
ch="abc".charAt(1); 返回'b'</span>
3、getChars()函数获取多个字符串
void getChars(int sourceStart,int sourceEnd,char target[],int targetStart)
sourceStart指定了子串开始字符的下标,sourceEnd指定了子串结束后的下一个字符的下标。因此,子串包含从sourceStart到sourceEnd-1的字符。
接收字符的数组由target指定,target中开始复制子串的下标值是targetStart。
String s="this is a demo of the getChars method.";
char buf[]=new char[20];
s.getChars(10,14,buf,0);
4、getBytes()函数
替代getChars()的一种方法是将字符存储在字节数组中,该方法即getBytes()。
5、toCharArray()函数
将字符串对象中的字符转换成一个字符数组