[java]代码库
/**
* 比较字符串是否相等
*
* @param str
*/
public static void testEqualsStr(String str) {
// equals方法比较字符串的值想否相等
System.out.println("str.equals(\"I am in Beijing\") = "
+ str.equals("I am in Beijing"));
// equalsIgnoreCase方法比较字符串的值时不去分大小写
System.out.println("str.equalsIgnoreCase(\"I am in Beijing\") = "
+ str.equalsIgnoreCase("I am in Beijing"));
// startsWith方法判断字符串是否以某个子字符串开始
System.out.println("str.startsWith(\"Th\") = " + str.startsWith("Th"));
// endsWith方法判断字符串是否以某个子字符串结束
System.out.println("str.endsWith(\"t!\") = " + str.endsWith("t!"));
}