you can't access Teacher class in Teacher_A because you have defined as below:
private static class Teacher
A nested class will behave like member of class only, so if your nested class is private then you can access it outside the class.
for more details see Nested Classes
Let say you change access specifier from private to package or public still you can't create object of your Teacher class because you have made constructor as private:
private Teacher(String x, String y)
From JLS 6.6.1. Determining Accessibility
if the member or constructor is declared private, then access is permitted if and only if it occurs within the body of the top level class (§7.6) that encloses the declaration of the member or constructor.
but anyway if you want to run this change Access Control 1 ex:
package sample;
import sample.Person.Teacher;
public class Teacher_A {
public static void main(String[] args) {
//new Teacher Object here ....
Teacher aa = new Teacher(null,null);
}
}
package sample;
public class Person{
protected Person(String x, String y){
//your code
}
static class Teacher{
Teacher(String x, String y){
//your code
}
}
}