Skip to main content

Checkpoint: Text Toolkit

beginner45 min readLesson 25 of 180

Three string utilities with precise contracts: decomposition, null-safety, and boundary thinking in one library.

The Text Toolkit is a small library with a clean contract. Implement:

  1. static String initials(String fullName) — the first letters of the words, upper-cased and joined. initials("ada byron lovelace") is "ABL". Extra spaces between words are ignored; an empty or null name gives "".
  2. static boolean isPalindrome(String text) — true when text reads the same forwards and backwards, ignoring case and every non-letter (isPalindrome("A man, a plan, a canal: Panama!") is true — it reduces to amanaplanacanalpanama, which reads the same both ways). Null or empty after cleaning is false.
  3. static String truncate(String text, int max) — text shortened to at most max characters, with "..." appended only when shortening happened. truncate("programming", 7) is "program" + "..."; a text already within the limit comes back untouched. max below 4 (no room even for the dots) returns just the first max characters with no dots.

Every method returns a value; none prints. Build helpers if useful — the grader only calls the three public entry points.