Home

This Chapter
-Chapter 14: Nested and Inner Classes
-An Overview of Nested Classes
-Static Nested Classes
-Member Inner Classes
-Local Inner Classes
-Anonymous Inner Classes
-Behind Nested and Inner Classes
-Summary
-Questions

Table of Contents
-Introduction
-Chapter 1: Your First Taste of Java
-Chapter 2: Language Fundamentals
-Chapter 3: Statements
-Chapter 4: Objects and Classes
-Chapter 5: Core Classes
-Chapter 6: Inheritance
-Chapter 7: Error Handling
-Chapter 8: Numbers and Dates
-Chapter 9: Interfaces and Abstract Classes
-Chapter 10: Enums
-Chapter 11: The Collections Framework
-Chapter 12: Generics
-Chapter 13: Input Output
-Chapter 14: Nested and Inner Classes
-Chapter 15: Swing Basics
-Chapter 16: Swinging Higher
-Chapter 17: Polymorphism
-Chapter 18: Annotations
-Chapter 19: Internationalization
-Chapter 20: Applets
-Chapter 21: Java Networking
-Chapter 22: Java Database Connectivity
-Chapter 23: Java Threads
-Chapter 24: Security
-Chapter 25: Java Web Applications
-Chapter 26: JavaServer Pages
-Chapter 27: Javadoc
-Chapter 28: Application Deployment
-Appendix A: javac
-Appendix B: java
-Appendix C: jar
-Appendix D: NetBeans
-Appendix E: Eclipse

Previous
Next

 

Chapter 14

Nested and Inner Classes

Nested and inner classes are often considered too confusing for beginners. However, they have some merits that make them a proper discussion topic in this book. To name a few, you can hide an implementation completely using a nested class, and it provides a shorter way of writing an event-listener.

One of the reasons nested and inner classes sometimes seem overly complex is because the terms “nested classes” and “inner classes” are often used to mean different things in different texts. This book will stick to the definitions in The Java Language Specification, Third Edition, which is the formal specification from Sun Microsystems (http://java.sun.com/docs/books/jls/).

This chapter starts by defining what nested classes and inner classes are and continue by explaining each type of nested classes.

Previous
Next