1.String API:
class StringDemo1115 { public static void main(String[] args) { String oneName = "XiaoMing"; System.out.println(oneName.equalsIgnoreCase("xiaoming")); // true System.out.println(oneName.startsWith("Xiao")); // true System.out.println(oneName.endsWith("Ming")); // true String smallerName = "Kong"; String equalsName = "XiaoMing"; String biggerName = "Zhong"; if (oneName.compareTo(biggerName) < 0) { System.out.println("smaller than " + biggerName); // smaller than Zhong } if (oneName.compareTo(smallerName) > 0) { System.out.println("bigger than " + smallerName); // bigger than Kong } if (oneName.compareTo(equalsName) == 0) { System.out.println("equals " + equalsName); // equals XiaoMing } } }
String部分API 思维导图: