#techbrainster
#kotlininnerclass
#howtodefinedinnerclassinkotlin
#kotlintutorial
#techbrainster
inner class in kotlin,how to create inner class and use of inner class
In this video we are going to learn about inner class in kotlin,how to create inner class and use of inner class
When we can declare a class inside another class using the keyword inner then it is
called inner class. With the help of the inner class, we can access the outer class
property inside the inner class
class Outer{
// Members of Outer class
inner class Inner{
// Members of Inner class
}
}
In an inner class:
● inner class maintains an instance of the outer class So, it can
access members of the outer class.
● cannot declare an inner class inside an interface or non-inner
class.
● cannot directly create an object of the inner class. It can be
created using the outer class object.
val outerObj = Outer()
// using outer class object to create inner class object
val innerObj = outerObj.Inner()
Instagram - / techbrainster
facebook - / techbrainster
Twitter - / pankajk51736731
[email protected]