- 练习字符串的反转
- 如何去除字符串前后空格
- 如何去除字符串所有空格
public class StringUtils {
public static String DeleteBlankSpace(String s){
while(s.startsWith(" ")){
s=s.substring(1);
while(s.endsWith(" ")){
s=s.substring(0,s.length()-1);
}
}
return s;
}
public static String DeleteAllBlankSpace(String s){
int i=0;String s1="";
do{
if(s.charAt(i)!=' '){
s1+=s.charAt(i);
}
i++;
}while(i<s.length());
return s1;
}
public static String Reversal(String s,int start,int end){
String s1;
s1=s.substring(0,start);
int i=end;
do{
s1+=s.charAt(i);
i--;
}while(i>=start);
s1+=s.substring(end,s.length()-1);
return s1;
}
}