Questions
I have a "private static" nested class in Java. What is the significance of access modifiers for fields and methods inside this class? I ve tried both public and private with no effect on my application.
public class MyList<T>{
private static class Node{ // List node
private Object item;
private Node next;
private Node prev;
private Node(Node next){
this.next = next;
}
private static Node doStuff(){}
}
}
Answers
Two kinds of nested classes: 1. Static (nested class) and 2. Non-static (also called inner class)
Now, the Outer class, MyList can access all the members of the inner class Node, but you actually use the access specifiers for the members of the class Node (nested class) when you want restrictions of some external class accessing it.
http://www.developer.com/java/article.php/859381
http://www.developer.com/java/article.php/859381
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/4075262/access-modifiers-inside-a-private-static-nested-class-in-java
Related