Class Package:
What Is a Package?
A package is a namespace that organizes a set of related classes and interfaces.
Conceptually you can think of packages as being similar to different folders on
your computer. You might keep HTML pages in one folder, images in another,
and scripts or applications in yet another. Because software written in the Java
programming language can be composed of hundreds or thousands of individual
classes, it makes sense to keep things organized by placing related classes and
interfaces into packages.
The Java platform provides an enormous class library (a set of packages) suitable for use
in your own applications. This library is known as the "Application Programming
Interface", or "API" for short. Its packages represent the tasks most commonly
associated with general-purpose programming. For example, a String object
contains state and behavior for character strings; a File object allows a
programmer to easily create, delete, inspect, compare, or modify a file on the
filesystem; a Socket object allows for the creation and use of network sockets;
various GUI objects control buttons and checkboxes and anything else related to
graphical user interfaces. There are literally thousands of classes to choose from.
This allows you, the programmer, to focus on the design of your particular
application, rather than the infrastructure required to make it work.
The Java Platform API Specification contains the complete listing for all packages,
interfaces, classes, fields, and methods supplied by the Java SE platform. Load
the page in your browser and bookmark it. As a programmer, it will become your
single most important piece of reference documentation.
Summary of Chapter 1
The two defining characteristics of object – oriented programming
are encapsulation in which data and methods are packaged within
a class , and inheritance.in which a (sub) class that specialize
another (super) class inherits the latter’s data and methods.
Encapsulation separates interface from implementation , making
for code that is robust and easy to maintain
Reuing encapsulation means using an object time and again as a
component in other objects: this is reuse by composition.
A class is a blueprint for the creation of objects , and prescribes
the state attributes and behavior of its instances or objects.
An object once created is alive so long as there is at least one
reference to it.When there are no longer any references to an
object it’s automatically reclaimed by the garbage collector. which
can then recycle the space used by this object.
Two methods in a class with the same name but different
signatures are said to be overloaded.
Static fields and methods are properties
of the class , and not
specific to any object-they can be used directly via the class name ,
without going through an object.
All classes in Java implicitly extend a root class called object.
The Object class provides several methods that have default
implementations including the methods equals , toString . and
clone All classes inherit these methods . but most would want to
override them in order to
provide their own specific
implementations
Java programs use exceptations to signal errors
Exceptions are of two kinds: unchecked or runtime exceptions ,
and checked
or compile-time exceptions
Input and output connected to the terminal can be done via the
System.in.System.err streams.
The java.until.Scanner and java.until.StringTokenizer classes are
adequate for most kind of input processing.
Large Java applications are typically organized into packages of
classes.
The package hierarchy in a java application has a one-to-one
correspondence with organization of the constituent
classes on
the file system.
They type used to declare a reference is its static or compile-time,
type, while the type of object it points to is its dynamic or runtime,
type
An interface may extend another interface. just as a class may
extend another class.
A generic class is one that allows a choice of client-defined
types
of concretize it .
A generic class defines a parameter type in its header.
An interface can be made generic, just like a class.