Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 444 Bytes

File metadata and controls

20 lines (14 loc) · 444 Bytes

Private Inner Classes

Both static and regular inner classes can be marked as private.

class Human {
    // No other class can see this human's thoughts
    private class Thoughts {

    }

    // Nor can they see their feelings
    private static class Feelings {

    }
}

Within the class they are defined, a private inner class works as normal. The difference is that code outside the class cannot make instances of them.