Category: Advantages of Exception Handling
-
Comparing Strings – Selected API Classes
Comparing Strings Characters are compared based on their Unicode values. Click here to view code image boolean test = ‘a’ < ‘b’; // true since 0x61 < 0x62 Two strings are compared lexicographically, as in a dictionary or telephone directory, by successively comparing their corresponding characters at each position in the two strings, starting with…
-
Extracting Substrings from Strings – Selected API Classes
Extracting Substrings from Strings The String class provides methods to trim and strip strings, and also extract substrings. boolean isBlank() Returns true if the string is empty or contains only whitespace; otherwise, it returns false. See also the method isEmpty() in the CharSequence interface (p. 444). String strip()String stripLeading()String stripTrailing() Return a string whose value…