Comparison between a normal or regular class and a static nested class.
S.NO | Normal/Regular inner class | Static nested class |
---|---|---|
1. | Without an outer class object existing, there cannot be an inner class object. That is, the inner class object is always associated with the outer class object. | There may be a static nested class object if an outer class object does not exist. That is, the outer class object is not linked to the static nested class object. |
2. | Static members cannot be declared inside a normal/regular inner class. | Static members can be declared inside a static nested class. |
3. | Regular inner classes cannot be invoked directly from the command prompt because the main() method cannot be declared. | The static nested class can be invoked directly from the command prompt because the main() method can be declared. |
4. | Outer class members can be accessed directly, both static and non-static. | A static member of the outer class is the only one that can be directly accessed. |
Note: also read about the Nested Class in Java
If you like my post, please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
You are given a stream of elements that is too large to fit into memory.…
The formula for the area of a circle is given by πr². Use the Monte…
Given an integer k and a string s, write a function to determine the length…
There is a staircase with N steps, and you can ascend either 1 step or…
Build an autocomplete system that, given a query string s and a set of possible…
Design a job scheduler that accepts a function f and an integer n. The scheduler…