读书人

判断最后的字符是否possible

发布时间: 2012-08-22 09:50:35 作者: rapoo

判断最后的字符是不是possible
1,判断最后的字符是不是possible, 用endswith方法,接下来再替换
2,替换最后一个可以变项的作

String s = "The possible problem is, How is that possible";
if(s.endsWith("possible")){
String s1 = s.substring(0, s.lastIndexOf("possible"));
s = s1 + "impossible";
}
System.out.println(s);

读书人网 >操作系统

热点推荐