Objects & ClassesHomepage  « Learn Java5 « Objects & Classes

In the last section we made sparing use of any object other than the predefined data type String used in the main() method parameter list. The main emphasis of the Beginning Java5 section of the site was an introduction to the basic building blocks required to write a java program. Most of the exercises involved running the main() method, to highlight features of the language such as conditional and looping statements. Hopefully performing these tasks has become second nature through the various coding, tests and quizzes we did in that section.

But Java is so much more than this and at its very core is the concept of classes that define the state and behaviour of objects. From the Java perspective, the class forms the basis of the object-oriented programming paradigm. A well designed class should define a logical entity that fits a particular requirement within the application as a whole. For example a customer class may hold customer information but the history of Greece and the colour of cheese is irrelevant, unconnected and should not be included within the customer class. We will go into more details of this when we cover OO concepts, for now lets think of a class as a template for an object. The class holds data relevant to the object in question and code that processes that data. We place the code for processing the data into methods. The data and methods of a class, more commonly known as members, are what make up the building blocks of an object. With the members defined we have the blueprint to create (instantiate), interrogate and modify the state of an object. Of course this blueprint is an abstraction and no instances of an object exist until we actually instantiate them within a class.

We will cover the concepts paragraphed above as we work our way through the lessons in this section, but we will we start it by looking at a predefined data type, the Array object. Investigation of this class will give us an insight into using objects and classes before we start to create our own.


Arrays

In this lesson we start our investigation of objects and classes by looking at arrays and how to use them. In Java the predefined data type Array object is used for array manipulation. Investigation of this object will give us an insight into using classes before we start to create our own.


Class Structure & Syntax

A class is made up of members that form a blueprint for an object and its behaviour. In this lesson we look at the members that constitute the structire of a class and the syntax required for class construction.


Reference Variables

Java comes with two types of variables to choose from, primitives and reference. In this lesson we look at reference variables and how to use them in Java. We discussed primitive variables in the Beginning Java5 section in the Primitive Variables lesson.


Methods

We have used methods throughout the lessons so far, so its time for a thorough investigation of what we can do with these members.

Instance Variables & Scope

In Java we declare variables anywhere within a block of code and instance variables are defined within a class but outside any methods. Instance variables can be declared anywhere within class scope, but by convention they are declared before any methods of the class.. In this lesson we investigate instance variables, how to use them and their scope.


Constructors

In this lesson we look at constructors, which are used to create instances of our classes and can be added explicitly within our code or implicitly added by the compiler.


Static Members

We have used the static keyword throughout the lessons so far, in this lesson we investigate what static means and how to apply it to our class members.


Enumerations

In this lesson we go through enumerations which are also known as enumerated types or enums and were introduced in Java5.


<<  Loop Statements                    Arrays  >>

go to home page Java5 Tutor Homepage go to top of page Top





All the Java5 Objects & Classes lessons are listed below. Click a link to go to that lesson.


Objects & Classes

Arrays

Class Structure & Syntax

Reference Variables

Methods

Instance Variables & Scope

Constructors

Static Members

Enumerations