Trimming whitespace from strings
🔹 1️⃣ String.trim() The classic method for removing whitespace from both ends of a string. Syntax: String trimmed = str.trim(); String trimmed = str.trim(); Behavior: Removes leading and trailing whitespace. Whitespace includes:spaces (' '), tabs ('\t'), newlines ('\n'), carriage returns ('\r'). ✅ Example: String s = " Hello World! "; System.out.println(s.trim()); String s =…
