1. Home
  2. Computing & Technology
  3. Java

Designing and Creating Objects

By , About.com Guide

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

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. Designing and Creating Objects>

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

All rights reserved.