Posts

Showing posts with the label Types

Class in Java

We can categorize java classes in several criteria criteria-1 1. Top Level class We can create any number of top level class, interfaces, enumerators, annotations inside the java file. But we can add only one public top level class in that & that class name must be the  name  of the java file. Top level class cant be static. public class AppInitializer {//file name: AppInitializer.java } class A{ } interface B{ } @interface C{ } enum D{ } 2.Nested Class    2.1  Static Class    2.2) Non-static Nested class(Inner Class)         2.2.1) Regular inner class         2.2.2) Local Inner Class               2.2.2.a) Anonymous Inner Class eg:-Nested class           class AppInitializer {     class C{     }     static class B{     } } Q-A)Can we create inner class inside the interface? //If we create a class in interface,it will be implicitly static.  interface A {     // Directly cant create inner class in  the interface(But can create indirectly).Class will be implicitly static class     //