The inner class

Inner class definition

Inner class StaticInner} fun main() {val inner: Outer.Inner = Outer().Inner() val staticInner: Outer.StaticInner = Outer.StaticInner() }Copy the code

Internal Object

OuterObject{// The inner Object has no non-static state, Do not use inner decoration object StaticInnerObject} fun main () {val StaticInnerObject = OuterObject. StaticInnerObject}Copy the code

Anonymous inner class

Fun main() {// Anonymous inner class val runnable = object: Runnable {override fun run() {}} // Cross type: Cloneable & Runnable val runnable2 = object: Cloneable,Runnable { override fun run() { } } }Copy the code

Local classes and local functions

Fun main() {// Local class; Class LocalClass{} // local function; Fun localFunc(){}}Copy the code

The inner class

Inner class definition

Inner class StaticInner} fun main() {val inner: Outer.Inner = Outer().Inner() val staticInner: Outer.StaticInner = Outer.StaticInner() }Copy the code

Internal Object

OuterObject{// The inner Object has no non-static state, Do not use inner decoration object StaticInnerObject} fun main () {val StaticInnerObject = OuterObject. StaticInnerObject}Copy the code

Anonymous inner class

Fun main() {// Anonymous inner class val runnable = object: Runnable {override fun run() {}} // Cross type: Cloneable & Runnable val runnable2 = object: Cloneable,Runnable { override fun run() { } } }Copy the code

Local classes and local functions

Fun main() {// Local class; Class LocalClass{} // local function; Fun localFunc(){}}Copy the code