手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

Java 如何判断字符串以什么后缀结尾

时间:2024-10-17 00:56:32

1、在java中,要判断某个字符串是否以某字符串结尾,使用字符串的方法endsWith可实现boolean java.lang.String.endsWith(String suffix)判断当前字符串是否以后缀suffix结尾,返回真或假,真表示以suffix结尾,假表示不以suffix结尾举例:String s = "helloWorld"; if (s.endsWith("World")) { System.out.println("字符串以World结尾"); } else { System.out.println("字符串不是World结尾"); }输出结果为:字符串以World结尾

© 手抄报圈