How to Create instances of inner classes?

public class MainClass {
class A {
private int i = 11;

public int value() {
  return i;
}

}

class B {
private String label;

B(String whereTo) {
  label = whereTo;
}

String readLabel() {
  return label;
}

}

public static void main(String[] args) {
MainClass p = new MainClass();
// Must use instance of outer class
// to create an instances of the inner class:
MainClass.A c = p.new A();
MainClass.B d = p.new B(“A”);
}
}