Java inner class (Implementing Single Linked List)

This question already has an answer here:

  • Java inner class and static nested class 23 answers

  • Because head is an attribute of the LinkedList class

  • Nope, but you're welcome to move the field afterwards

  • Java inner class and static nested class


  • 1) Head is defined outside of the inner class because the inner class does not need a "Head" field, but the outer class does.

    2) No, it doesn't.

    3) As the comment says, it is defined as static so that main() can access it.

    链接地址: http://www.djcxy.com/p/92022.html

    上一篇: Java比较器语法的作品,但为什么?

    下一篇: Java内部类(实现单个链接列表)