Nested classes and interfaces combinations in Java Here we discuss, 4 types of nested classes and interfaces combination with examples. Class inside a Class Interface inside a Class Interface inside an interface Class inside an interface So lets see all 4 categories one one by with examples. 1. Class inside a Class Class inside another class refer as nested class. The class written within is called the nested class, and the class that holds the inner class is called the outer class. class Outer { class Inner { public void innerMethod() { System.out.println("Class inside a Class Example"); } } public static void main(String[] args) { Outer.Inner obj = new Outer().new Inner(); obj.innerMethod(); // We can also do following way // new Outer().new Inner().innerMethod(); } } We can not create inner class object until outer class object is not created. 2. Interface inside a Class W
Welcome To Programming Tutorial. Here i share about Java Programming stuff. I share Java stuff with simple examples.