Can you declare a class as private?

Q

Can you declare a class as private?

✍: Guest

A
Yes, we can declare a private 
class as an inner class. For example,

class MyPrivate {
    private static class MyKey {
        String key = "12345";
    }
    public static void main(String[] args) {
System.out.println(new MyKey().key);//prints 12345
    }
}

2012-08-23, 2297👍, 0💬