Java is one of many languages that is referred to as object oriented. Object oriented programming or OOP is relatively new and quite logical. What makes programming objects harder to understand than swim fins and baseball objects is that they are abstract. You can't see them or feel them or swing them. However, you can classify them and you can name them so objects will have classifications such as packages, classes, interfaces, variables, etc. and names like package java.applet, class java.applet.Applet, interface Runnable, and variable boolean gameOver. The preceding examples are all objects. Everything in Java is an object. The above objects in Java are already coded for you by other Java programmers. When you call them(name them) in your program, the Java language reader(Java Virtual Machine or JVM) in your user's browser knows what they are and what their properties are. You can use these objects with their existing properties to paste them together to make new objects much like you did in the RhollSwimmer example. And like you did in the RhollSwimmer example, you can create instances of these objects with new properties.

These will be the main objects(packages, classes, interfaces, and variables) that we will use to construct our programs. In this class, we will use the packages and interfaces as they are in existing Java code. We will not create new packages or interfaces, merely call them in our programs to use them as is. We will create new instances of classes and variables. So to create new instances of a class or a variable, we will have to give them names. Java, like Javascript was, is case sensitive. While it doesn't matter whether you use capitals or lowercase as long as you are consistent, we will follow the standard Java syntax for these names. Classes start with a capital letter and use a capital letter for each new word in the name, stringing these words into one word. RhollSwimmerBlack was a class-like name. You can use any words you want to create your new classes as long as you capitalize the first letter of each part of the word(ex. classes MyRectangle, BoxBorder, etc.). Variable names start with all lower case letters for the first part of the word and capitalize the first letter of each added on word. We did not have any examples of variables in the rholl analogy, but variables always have a "type of variable" word in front of them. That type is usually a class name or a basic variable type like integer, string, or boolean. Some examples of variables that might be part of the RhollSwimmer example would be Mask strapColor, int finNumber, boolean isDressed. Variable names in Java are almost always named by you, the local programmer. In this class, we will mostly use existing Java packages and interfaces, use or extend some existing Java classes and create some of our own. We will create all of our own variables.

Common Objects We Will Use
  • Packages- a large object containing smaller objects(classes and interfaces). Examples of packages we will use are java.lang, java.applet, java.awt, and java.util.. These are huge and we will not create new packages, but just use the above four. The package java.lang is automatically "on" and available whenever Java starts up, but the other 3 needed to be "imported". The command at the beginning of your program for importing any of these 3 packages is import java.awt.* if all of the java.awt package is desired. The * symbol says import all of the java.awt package. You could also just import one class of the java.awt package by typing import java.awt.Button if you just needed that one class of package java.awt. I almost always import the entire package.
  • Classes- think of classes as templates for building a new object. Existing classes have certain variables that describe the object and methods that describe how the class behaves. The many classes we will use are listed in Appendix C in the back of your book. Since we will mostly be dealing with packages java.awt, java.applet, java.util, and java.lang, take some time to glance over the names of the classes in those packages.
  • Interfaces- abstract groups of methods that can be applied to a class. Some people think of interfaces as "special classes of behaviors" that can be applied to other classes. To apply an interface to a class, use the word implements to assign an interfaces methods to a class you created. An example would be the following code:
    public class Jeff extends java.applet.Applet
    implements Runnable {
    other code, etc
    }
    In the above example, the name of the interface is Runnable. Jeff is the made up class or instance of the class Applet(java.applet.Applet).
  • Variables- variables are the smallest of the 4 groups of objects. They define one attribute of a class. So, a class can have many attributes/variables. Variables are your made up names, but remember they start with a lower case letter and each added on word starts with an upper case letter. Examples of variables might be highScore, topCardSuite, bicycleColor, etc..

So let's see how it all comes together,
... a sample applet


Index Grading Schedule Syntax JavaDocs Video Projects Links