Java Reference
In-Depth Information
Inner classes often give rise to a similar situation. After a single object of the
Rectangle-Measurer has been constructed, the class is never used again. In
Java, it is possible to define anonymous classes if all you ever need is a single
object of the class.
public static void main(String[] args)
{
// Construct an object of an anonymous class
Measurer m = new Measurer()
// Class definition starts here
{
public double measure(Object anObject)
{
Rectangle aRectangle = (Rectangle)
anObject;
double area = aRectangle.getWidth() *
aRectangle.getHeight();
return area;
}
};
DataSet data = new DataSet(m);
. . .
}
405
406
This means: Construct an object of a class that implements the Measurer
interface by defining the measure method as specified. Many programmers like
this style, but we will not use it in this topic.
R ANDOM F ACT 9.1: Operating Systems
Without an operating system, a computer would not be useful. Minimally, you
need an operating system to locate files and to start programs. The programs that
you run need services from the operating system to access devices and to interact
with other programs. Operating systems on large computers need to provide more
services than those on personal computers do.
Here are some typical services:
ȗ Program loading. Every operating system provides some way of launching
application programs. The user indicates what program should be run,
Search WWH ::




Custom Search