What is NumberFormatException in Java

Chapter 9: Exception handling

Practice creates masters

You can purchase the solutions to all of the exercises in this book as a ZIP file.

  1. Develop a Java application in which the string "09/16/2002" is interpreted and recognized as a valid date. Use the method of the class to do this. It's not a static method, so you need to get an object of the type beforehand. You do this by calling the static method on the class that returns an object of type. The character string "09/16/2002" is passed to the method as the only parameter. If the character string cannot be identified as a valid date, an exception of the type occurs. If the character string is interpreted as a valid date, an object of the type is returned. Call the method on this object that does not expect a parameter and returns the time in the form of a string. Output this string to check the standard output.

  2. Develop a Java application in which you can create an array of any data type of any size. Access the array by intentionally using an invalid index in square brackets. In this case, an exception of the type occurs. Add a - clause to your code to catch this exception.