The last chapter ended with a Java program that could survive an exception and run two threads. Now let's give it something practical to do. Open any mobile-banking app and look at the send-money form. It asks for a name, a mobile number and an amount, and whatever you type arrives in the program as plain text: " Rafiq " with stray spaces around it, 01712345678, and 1,250 with a comma in the middle. Before a single taka moves, the program has to clean the name, turn the text 1,250 into a number it can add a Tk 15 fee to, compare the entered username with the stored one without caring about capitals, and print the total with exactly two decimals. None of this is clever. It is the daily work of every Java program, and Java ships a library for it, so you never write it from scratch.
This chapter is a tour of that library, the four pieces that Java papers ask about again and again. The first is String, Java's text. The second is StringBuilder and StringBuffer, the tools you reach for when text must be built or edited. The third is the wrapper classes (Integer, Double and the rest), which let a plain number behave like an object, along with the surprising rules of autoboxing and the Integer cache. The fourth is Math, with its rounding methods that behave differently for negative numbers.