继续第五章

字符串操作。

获取子字符串,substring(int beginindex),返回从指定位置开始到字符串结尾的字符串。substring(int beginindex,int endindex),返回指定起始于结束位置的字符串。

去除空格,str.trim(),返回字符串的副本,忽略前导空格与尾部空格。

字符串替换。str.replease(char oldChar,char newChar),返回新字符串

判断字符串开始于结尾,str.startsWith(String prefix),prefix是前缀字符串,str.endsWith(String suffix),suffix是后缀字符串,

判断字符串是否相等。str.equals(String otherstr),返回true和false,str.equalslgnoreCase(String otherstr),区分大小写。

按照字典顺序比较字符串。str.compareTo(String otherstr),string在参数之前,返回正整数,相等返回0,繁反之返回负整数。

 

posted on 2020-08-03 21:08  sean1246  阅读(33)  评论(0编辑  收藏  举报