What is inner classes in java? | SoloLearn: Learn to code for FREE!


What is inner classes in java?

2/14/2018 8:15:24 PM

AJ #L1G3

5 Answers

New Answer


A class defined inside another class which may or may not be private.


class OuterClass { class InnerClass { // this class is inside another class } }




Any non-static nested class is known as inner class in java. Java inner class is associated with the object of the class and they can access all the variables and methods of the outer class. Since inner classes are associated with instance, we can’t have any static variables in them.


🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! You can read all about inner class with examples. Inner classes have some rules also please visit here: https://javagoal.com/nested-classes/