Program 6.3: A Web Site Class with a Print Method

The classes you've seen in previous chapters have all had a single method, main. However many classes will have many different methods to do many different things. For instance the website class might have a method to print its data. Such a class might look like program 6.3.

public class website {

  public String name;
  public String url;
  public String description;
  
  public void print() {
    System.out.println(name + " at " + url + " is " +
      description);
  }

}

Copyright 1996 Elliotte Rusty Harold
elharo@sunsite.unc.edu
This Chapter
Examples
Home