public class FirstDemo {

  /**
    *API中String的常用方法
    */

  // 判断是否以制定的字符串开头或结尾
  public static void main(String[] args) {

    String str1 = "asdfg";
    String str2 = "asdfghjkl";
    if (str1.startsWith("as")) {
      System.out.println("str1是以“as”开头的");
    }
    if (str2.endsWith("kl")) {
      System.out.println("str2是以“kl”结尾的");
    }
  }

}