## **截取当前字符串的部分内容**
String subString(int start,int end)
public static void main(String[] args) {
String str = "http://www.oracle.com";
String sub = str.substring(11,17);
System.out.println(sub);
sub = str.substring(11);
System.out.println(sub);
int start = str.indexOf(".");
int end = str.indexOf(".",start+1);
sub = str.substring(start+1,end);
System.out.println(sub);
}
去除字符串两边的空白
**String trim()
public static void main(String[] args){
String str = " Hello world ";
String trim = str.trim();
System.out.println(str);
System.out.println(trim);
}
获取给定位置上的字符
char charAt(int index)
public static void main(String[] args){
String str = "Hello world";
char c = str.charAt(6);
System.out.println(c);
str = "上海自来水来自海上";
for(int i = 0;i < str.length()/2; i++){
if(str.charAt(i) != str.charAt(str.length()-1-i)){
System.out.println("不是回文");
return;
}
}
System.out.println("是回文");
}