This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: COMP 250 Winter 2010 34 - modifiers April 12, 2010 Java modifiers [Note: some of this is taken from the Readings BackgroundJava.pdf which I posted early in the course. I have added further details that involve concepts from inheritance.] Packages A package is a particular set of classes. Go to the Java API http://java.sun.com/j2se/1.5.0/docs/api/ . and notice that in the upper left corner of that page is a listing of dozens of packages. A few of them that you are familiar with are: java.lang - Object, String, Math, ... java.util- has many of the data structure classes that we will use in this course, such as LinkedList , ArrayList , HashMap The full name of a class is the name of the package following by the name of the class, for ex- ample java.lang.Object or java.util.LinkedList . You can have packages within packages e.g. java.lang is a package within the java package. You can also make your own packages, of course. For example, the classes Beagle and Dog might belong to package comp250.lectureExamples , and so the full name of the classes would be comp250.lectureExamples.Beagle and comp250.lectureExamples.Dog . A package has a tree structure. Packages are directories, typically internal nodes 1 ). The classes within a package are leaves. [ASIDE: The issue of how file systems and packages are organized is important in practice, but I did not discuss it in class. If you want to learn about package trees and how they correspond to file directories (and to www URLs) then you read through the following: http://cs.armstrong.edu/liang/intro6e/supplement/packages.pdf ] When you are writing a class and you want to identify the class as being part of a particular package, you start the class with the package name. The first line of your class file will be package PackageName...
View Full Document