Is it possible static class in Java? The answer is both "YES" and "NO". Let us see. Java comes with two types of classes – top-level classes and inner classes (also known as nested classes). A top-level class cannot be static where as a nested class can be static. Top-level…
Inner classes Tutorial Java 1. What is inner class in Java? Explain with example? 2. What is nested class in Java? Explain clearly? A class declared within another class is known as inner class or nested class.
public class Demo // outer class
class Test // inner class or nested class
In the above code, Demo is known as outer class and Test…
Restriction on Static Nested Classes static keyword can be applied on classes and interfaces only when they are nested. Top-level classes and interfaces cannot be static. This is the second variation of the total six discussed in this series. Note: It is advised to read the basics and types of…