https://www.codewars.com/kata/5aa736a455f906981800360d

public class Kata {

  public static boolean feast(String beast, String dish) {

    beast = beast.trim();
dish = dish.trim(); String beastBegin = beast.substring(0,1);
String beastEnd = beast.substring(beast.length()-1); String dishBegin = dish.substring(0,1);
String dishEnd = dish.substring(dish.length()-1); if(beastBegin.equals(dishBegin) && beastEnd.equals(dishEnd)){
return true;
}else{
return false;
} } }

更有甚者

public class Kata {

  public static boolean feast(String beast, String dish) {

    return beast.charAt(0)==dish.charAt(0) && beast.charAt(beast.length()-1) == dish.charAt(dish.length()-1);

  }

}
  
public class Kata {

  public static boolean feast(String b, String d) {
return d.startsWith(b.substring(0,0)) && d.endsWith(b.substring(b.length()-1));
} }
05-11 19:45