O'Reilly logo

Sams Teach Yourself Java™ in 24 Hours, Sixth Edition by Rogers Cadenhead

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Throwing and Catching Exceptions

For the next project, you create a class that uses exceptions to tell another class about an error that has taken place.

The classes in this project are HomePage, a class that represents a personal home page on the Web, and PageCatalog, an application that catalogs these pages.

Enter the text of Listing 18.4 in a new empty Java file called HomePage.

Listing 18.4. The Full Text of HomePage.java

 1: import java.net.*; 2: 3: public class HomePage { 4:     String owner; 5:     URL address; 6:     String category = "none"; 7: 8:     public HomePage(String inOwner, String inAddress) 9:         throws MalformedURLException {10:11:         owner = inOwner;12:         address = new URL(inAddress);13:     }14:15:     

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required