The Java Course provides a general introduction to programming in Java. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


What's Interesting?

Although Strings are objects, they are not very interesting objects, because

  • They are immutable.
  • They have no instance variables.
  • You don't have to use the new command to create one.

In this chapter, we are going to use two new object types that are part of the Java language, Point and Rectangle. Right from the start, I want to make it clear that these points and rectangles are not graphical objects that appear on the screen. They are variables that contain data, just like ints and doubles. Like other variables, they are used internally to perform computations.

The definitions of the Point and Rectangle classes are in the java.awt package, so we have to import them.



Last Update: 2011-01-24