Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Besides acting like a normal class, the wrappers have a bunch of really useful static methods. We’ve used one in this book before—Integer.parseInt().
The parse methods take a String and give you back a primitive value.
Converting a String to a primitive value is easy:
But if you try to do this:
You’ll get a runtime exception:
Every method or constructor that parses a String can throw a NumberFormatException. It’s a runtime exception, so you don’t have to handle or declare it. But you might want to.
(We’ll talk about Exceptions in the next chapter.)