Java

  1. Home
  2. Computing & Technology
  3. Java

Designing and Creating Objects

By Paul Leahy, About.com

1 of 7

Introduction

Before you read this step-by-step guide you might want to cast your eye over introduction to object-oriented programing. The Java code contained in the following steps matches the example of a Book object used in the theory of that article.

By the end of this guide you will have learned how to:

  • design an object
  • store data in an object
  • manipulate data in an object
  • create a new instance of an object

The Class File

If you're new to objects you will most likely be used to created Java programs using only one file – a Java main class file. It's the class that has the main method defined for the starting point of a Java program.

The class definition in the next step needs to be saved in a separate file. It follows the same naming guidelines as you have been using for the main class file (i.e., the name of the file must match the name of the class with the filename extension of .java). For example, as we are making a Book class the following class declaration should be saved in a file called "Book.java".

Explore Java

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Java

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

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

All rights reserved.