```class Outer { inner class Inner { p...
# getting-started
m
Copy code
class Outer {
    inner class Inner {
        private class Utils {}
    }
}
How can I declare a static nested class inside an
inner class
?
m
You can't, because in older Java that wasn't allowed, and we followed their restrictions pretty closely for the ease of j2k transition.
Feel free to make a YT issue if you believe lifting this restriction is important!
y
You can use nested type aliases if all you care about is the API shape of it all:
Copy code
class Outer {
    inner class Inner {
        private typealias Utils = Outer.Utils
    }
    private class Utils { }
}
You can also do something much weirder by using anonymous objects. This only works because the class is
private
in your example:
Copy code
class Outer {
    inner class Inner {
        private fun Utils() = object {
            val foo = 42
        }
        fun bar() {
            Utils().foo
        }
    }
}
I'd just use the nested typealias though