
package test; public class Testlianxi { public static void main(String[] args) { //判断fgh是否是字符串的最后一位 String str1="abcdefgh";
String str2="fgh";
int a = str1.lastIndexOf(str2); System.out.println("a="+a);
int b = str1.length(); System.out.println("b="+b);
int c = str2.length(); System.out.println("c="+c);
System.out.println("判断结果为"+(a==b-c)); System.out.println("用endWith判断的结果为"+str1.endsWith(str2));
} }