Dealing with exceptions is hard. For a while now in the Java world there are two camps. One considers the initial design of the Java exceptions system a sensible one, a feature that contributed greatly to Java’s success. A new camp has also formed in Java world and this new camp considers the original design [...]
Filed under: Java Exceptions, Java Language, Opinions by Daniel Pietraru
12 Comments »
An anonymous class in Java is a class with no specified name declared and instantiated at the same time. Because it has no name it can only be used once at place of declaration. Anonymous classes implement an interface or extend a class. They cannot declare their own constructors (they don’t have a name known [...]
Filed under: Java Language by Daniel Pietraru
Comments Off
Local inner classes are declared inside of a block of code. This block can be static bloc, a constructor, a method or simply a block of code surrounded with curly braces. These classes are only visible inside the enclosing bloc, but inside the block full hierarchies of classes can be developed. Local inner classes can [...]
Filed under: Java Language by Daniel Pietraru
Comments Off
An inner class is a class declared inside another class. The enclosing class can be a top level class or another inner class. The reason for using inner classes is to properly implement composition when the life of inner class instances are controlled by the outer class instance. Since the inner class instances are always [...]
Filed under: Java Language by Daniel Pietraru
2 Comments »
A nested interface is just a regular interface defined inside another class or interface. They are actually defined inside the body of the parent class, not only in the same file. The feature is useful for grouping related interfaces and for encapsulating interfaces in the classes where they are used.
Filed under: Java Language by Daniel Pietraru
Comments Off
A static nested class is a regular class defined inside of a package level class or inside of another static nested class. They are actually defined inside the body of the parent class, not only in the same file. As with any high level facility offered by a programming language it can be of real [...]
Filed under: Java Language by Daniel Pietraru
No Comments »