Class Outer
{
...
private class Node
{
private T data;
...
private T getData()
{
return data;
}
}
}
What’s the purpose of using set and get methods if the outer class can access inner class private members? What’s the purpose of making inner classes private? Package access?
Private Inner classes are written when you do not want the class to be exposed to external classes within or outside the package. They are used only inside the outer level class.
The getters and setters generally do not make sense inside a private classes because you can access the instance variables anyways.