Program 6.4: An OOPTest that uses the print method

Outside the website method you call the print method just like you reference member variables, using the name of the object you want to print and the . separator as demonstrated ins Program 6.4.

class OOPTest {

  public static void main(String args[]) {
    
    website w = new website();
    
    w.name = "Cafe Au Lait";
    w.url = "http://sunsite.unc.edu/javafaq/";
    w.description = "Really cool!";
    
    w.print();
    
  }
    
}

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