1. Home
  2. Computing & Technology
  3. Java

Designing and Creating Objects

By , About.com Guide

7 of 7

Multiple Objects

Now we can begin to see the power of objects. I could extend the program:

public class BookTracker {

   public static void main(String[] args) {

     Book firstBook = new Book("Horton Hears A Who!","Dr. Seuss","Random House");
     Book secondBook = new Book("The Cat In The Hat","Dr. Seuss","Random House");
     Book anotherBook = new Book("The Maltese Falcon","Dashiell Hammett","Orion");
     firstBook.displayBookData();
     anotherBook.displayBookData();
     secondBook.displayBookData();
   }
}

From writing one class definition we now have the ability to create as many Book objects as we please!

Explore Java
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Java
  4. Java Syntax
  5. Working With Objects
  6. Multiple Objects

©2009 About.com, a part of The New York Times Company.

All rights reserved.