O'Reilly logo

Beginning Java 8 Language Features: Lambda Expressions, Inner Classes, Th reads, I/O, Collections,and Streams by Kishori Sharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 2

image

Inner Classes

In this chapter, you will learn

  • What inner classes are
  • How to declare inner classes
  • How to declare member, local, and anonymous inner classes
  • How to create objects of inner classes

What Is an Inner Class?

You have worked with classes that are members of a package. A class, which is a member of a package, is known as a top-level class. For example, Listing 2-1 shows a top-level class named TopLevel.

Listing 2-1. An Example of a Top-Level Class

// TopLevel.javapackage com.jdojo.innerclasses;public class TopLevel {       private int value = 101;       public int getValue() {               return value;       }       public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required