Inner classes.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Mon, 28 Dec 2009 15:26:13 +0200
changeset 267 c513b3c60e73
parent 266 b186113f9492
child 268 b99a51c4e605
Inner classes.
java.rst
--- a/java.rst	Mon Dec 28 14:27:29 2009 +0200
+++ b/java.rst	Mon Dec 28 15:26:13 2009 +0200
@@ -14,3 +14,97 @@
 48       0           1.4
 49       0           1.5
 50       0           1.6
+
+* Modifiers.
+
+** public.
+
+ * Public class is visible in other packages.
+ * Public field is visible everywhere (class must be public too).
+
+** private.
+
+ * Private variables or methods may be used only by an instance of the same
+ class that declares the variable or method
+ * A private feature may only be accessed by the class that owns the feature.
+
+** protected.
+
+ * Is available to all classes in the same package and also available to all
+ subclasses of the class that owns the protected feature.
+ * This access is provided even to subclasses that reside in a different
+ package from the class that owns the protected feature.
+
+** default.
+
+What you get by default ie, without any access modifier.
+
+ * It means that it is visible to all within a particular package.
+
+* static.
+
+ * Static means one per class, not one for each object no matter how many
+   instance of a class might exist. This means that you can use them without
+   creating an instance of a class.
+ * Static methods are implicitly final, because overriding is done based on
+   the type of the object, and static methods are attached to a class, not an
+   object.
+ * A static method in a superclass can be shadowed by another static method in
+   a subclass, as long as the original method was not declared final.
+ * You can't override a static method with a nonstatic method.
+
+* final.
+
+ * A final class can't be extended ie., final class may not be subclassed.
+ * A final method can't be overridden when its class is inherited.
+ * You can't change value of a final variable.
+
+* Exceptions.
+
+A checked exception is some subclass of Exception (or Exception itself),
+excluding class RuntimeException and its subclasses.
+
+Unchecked exceptions are RuntimeException and any of its subclasses. Class
+Error and its subclasses also are unchecked. With an unchecked exception,
+however, the compiler doesn't force client programmers either to catch the
+exception or declare it in a throws clause.
+
+* Inner classes.
+
+** Nested top-level classes.
+
+If you declare a class within a class and specify the static modifier, the
+compiler treats the class just like any other top-level class.
+
+Any class outside the declaring class accesses the nested class with the
+declaring class name acting similarly to a package. eg, outer.inner. Top-level
+inner classes implicitly have access only to static variables. There can also
+be inner interfaces. All of these are of the nested top-level variety.
+
+** Member classes.
+
+Member inner classes are just like other member methods and member variables
+and access to the member class is restricted, just like methods and variables.
+This means a public member class acts similarly to a nested top-level class.
+
+The primary difference between member classes and nested top-level classes is
+that member classes have access to the specific instance of the enclosing
+class.
+
+** Local classes.
+
+Local classes are like local variables, specific to a block of code. Their
+visibility is only within the block of their declaration. In order for the
+class to be useful beyond the declaration block, it would need to implement a
+more publicly available interface.
+
+Because local classes are not members, the modifiers public, protected,
+private, and static are not usable.
+
+** Anonymous classes.
+
+Anonymous inner classes extend local inner classes one level further. As
+anonymous classes have no name, you cannot provide a constructor.
+
+
+