String
methods with boolean
resultsMethod name | Description |
---|---|
string.equals(string)
|
whether the two strings are identical |
string.equalsIgnoreCase(string)
|
whether the two strings are identical, ignoring capitalization |
string.startsWith(string)
|
whether this string begins with the characters of the given string |
string.endsWith(string)
|
whether this string ends with the characters of the given string |
string.contains(string)
|
whether the characters of the given string occur within this string |
String name = "Professor Smith"; if (name.startsWith("Prof")) { System.out.println("When are your office hours?"); }