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:
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"".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 toamanaplanacanalpanama, which reads the same both ways). Null or empty after cleaning isfalse.static String truncate(String text, int max)— text shortened to at mostmaxcharacters, with"..."appended only when shortening happened.truncate("programming", 7)is"program"+"..."; a text already within the limit comes back untouched.maxbelow 4 (no room even for the dots) returns just the firstmaxcharacters with no dots.
Every method returns a value; none prints. Build helpers if useful — the grader only calls the three public entry points.