With exception handling.

Lab Notes
Clarifying exception handling
by Matt Brenner
Listing 2. With exception handling.


1  public static final double
2  todouble (String text)
3  {
4       doubleval;
5
6
7       try {
8           val = Double.valueOf (text).doubleValue();
9       }
10     catch (NumberFormatException e) {
11         val = Double.NaN;
12     }
13
14     return (val);
15 }

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025