此方法判断此字符串是否以指定的后缀(suffix)结尾。
public boolean endsWith(String suffix)
这是参数的详细信息-
suffix - 后缀。
如果字符串是以suffix结尾,则返回true,否则为false。
public class Test { public static void main(String args[]) { String Str=new String("This is really not immutable!!"); boolean retVal; retVal=Str.endsWith( "immutable!!" ); System.out.println("Returned Value=" + retVal ); retVal=Str.endsWith( "immu" ); System.out.println("Returned Value=" + retVal ); } }
这将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/java/java-string-endswith.html
来源:LearnFk无涯教程网
Returned Value=true Returned Value=false
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)