`
zhangminok
  • 浏览: 4965 次
社区版块
存档分类
最新评论

判断最后的字符是不是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);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics