[SalesForce] Inner Classes/Interfaces

the guide says that one difference between Java and Apex is:

Inner classes and interfaces can only be declared one level deep inside an outer class.

Considering I know in Java what is an Inner class, an Interface and an Anonymous class, could you bring an example so to understand what "one level deep inside" means?
My guess is that could be something regarding OOP and the structure of inherithance a class or is considering the level deep as a nested structure, so that an inner classes

EDIT: there is an idea of Lambdas, please feel free to vote at this official link, if you are beginner, see how lambdas make the code more readable the code with this simple example

Best Answer

It means that an inner class can't have an inner class in Apex. So a structure like this is legal and common, especially when implementing patterns like wrapper classes or dependency injection:

public with sharing class OuterClass {
    private class InnerClass {
        // Members here.
    }

    // Members here
}

However, this structure is not legal Apex:

public with sharing class OuterClass {
    private class InnerClass {
        private class InnerInnerClass {
            // Members here.
        }

        // Members here.
    }

    // Members here
}

With the same prohibition applying for inner interfaces as inner classes.

Note that this stricture is written in terms of inner declaration. It's about the class nesting hierarchy, not the inheritance tree.

Related Topic