Java Reference
In-Depth Information
System.out.println("height = "+r.getHeight());
System.out.println("contains(15.0,
15.0)
=
"+r.contains(15.0, 15.0));
System.out.println("contains(0.0,
0.0)
=
"+r.contains(0.0, 0.0));
}
}
angle.Double(10.0, 10.0, 20.0, 30.0)
and then invokes its various
Rectangle.Float(10.0f, 10.0f, 20.0f, 30.0f)
before invoking
Rectangle
methods on this instance.
Compilebothlistings(
javac SMCDemo.java
or
javac *.java
)andrunthe
application (
java SMCDemo
). You will then observe the following output:
x = 10.0
y = 10.0
width = 20.0
height = 30.0
contains(15.0, 15.0) = true
contains(0.0, 0.0) = false
x = 10.0
y = 10.0
width = 20.0
height = 30.0
contains(15.0, 15.0) = true
contains(0.0, 0.0) = false
Java's class library contains many static member classes. For example, the
java.lang.Character
class encloses a static member class named
Subset
whose instances represent subsets of the Unicode character set.
java.util.AbstractMap.SimpleEntry
,
java.io.ObjectInputStream.GetField
,
and
java.security.KeyStore.PrivateKeyEntry
are other examples.