Java Reference
In-Depth Information
}
class Test {
public static void main(String[] args) {
Seq<String> strs =
new Seq<String>(
"a",
new Seq<String>("b",
new Seq<String>()));
Seq<Number> nums =
new Seq<Number>(
new Integer(1),
new Seq<Number>(new Double(1.5),
new Seq<Number>()));
Seq<String>.Zipper<Number> zipper =
strs.new Zipper<Number>();
Seq<Pair<String,Number>> combined =
zipper.zip(nums);
}
}
8.1.3. Inner Classes and Enclosing Instances
An inner class is a nested class that is not explicitly or implicitly declared static .
Inner classes include local (§ 14.3 ), anonymous (§ 15.9.5 ) and non-static member classes
8.5 ) .
Inner classes may not declare static initializers (§ 8.7 ) or member interfaces, or a compile-
time error occurs.
Inner classes may not declare static members, unless they are constant variables (§ 4.12.4 ) ,
or a compile-time error occurs.
Inner classes may inherit static members that are not constant variables even though they
may not declare them.
Nested classes that are not inner classes may declare static members freely, in accordance
with the usual rules of the Java programming language. Member interfaces (§ 8.5 ) are im-
plicitly static so they are never considered to be inner classes.
Example 8.1.3-1. Inner Class Declarations and Static Members
Click here to view code image
class HasStatic {
static int j = 100;
Search WWH ::




Custom Search