CS 112
Spring 2005
Ileana Streinu

Lecture 7

User-defined Objects and Classes in Java

So far we have developed programs mostly by modifying existing ones, or using a template. Now I start explaining the principles of object-oriented programming in Java and we learn how we create our own classes and objects. By learning how to define new classes and work with user-defined objects, we move into object oriented programming. It is a different, more advanced programming style, suitable for designing, developing and maintaining larger programming projects than the rather elementary exercises typically done in introductory programming classes.

I will introduce object oriented programming with a simple example, then we will work out a more complex program.

Simple Example How to work with this new class in Java. Here's an example, incorporating the new class into a complete Java program.

In-class exercise

this exercise.