code_junkie

Static nested class in Java, why?

Nov 12th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public class LinkedList<E> ... {
  2. ...
  3.  
  4. private static class Entry<E> { ... }
  5.  
  6. }
  7.  
  8. package test;
  9.  
  10. public class UpperClass {
  11. public static class StaticInnerClass {}
  12.  
  13. public class InnerClass {}
  14.  
  15. public static void main(String[] args) {
  16. // works
  17. StaticInnerClass stat = new StaticInnerClass();
  18. // doesn't compile
  19. InnerClass inner = new InnerClass();
  20. }
  21. }
Add Comment
Please, Sign In to add comment