Components of Java Technology


  • Language elements
    • Class-based OOPL with inheritance
    • A class is a template that defines how an object will look and behave once instantiated

  • Sample Java Code

    public class Point {
          private float x_;
          private float y_;
    
          public Point (float xval,
                   float yval)
              { x_=xval; y_=yval; }
    
          public float distanceFrom
                      (Point refpt)
                      {
          ...
       }
    }
    

Detailed description: 

"Now in this example, we show a doughnut. The doughnut shows a Point object, and inside the center is an x and a y value. Most often, data or values (instance variables) are located in the center of the doughnut. And on the outside are the functions (methods). In this case, we have a method called distanceFrom at the bottom of the doughnut. Think of this doughnut as jelly filled, rather than one with a hole. You really don't know what's inside until you bite into it and taste the jelly. In the same manner, think about the things in the center, the x and the y, as being encapsulated in the object (or hidden or isolated) so that the only way to get to the information in the center is through the outside. That's a basic principle of object-oriented programming."