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:     

Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.