String gg = "ifhiasjbhgagayrahahuaybcnzkfhi"; //1.lastIndexOf方法 String ll = "fhi"; //System.out.println(ll.length()); //System.out.println(gg.length()); if (gg.lastIndexOf(ll) == gg.length() - ll.length()) { System.out.println("判断 = " + true); } else System.out.println("判断 = " + false);
输出判断:
判断 = true