O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

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

6.9. Nested classes (Java inner classes)

C# allows you to write inner classes too. However, the rules are much simpler than in Java [16] when it comes to this. Java allows you to write four types of inner classes:

[16] Java has complex access privileges and scope for inner classes indeed.

  • static inner classes;

  • member inner classes (non-static inner classes – also known as nested classes);

  • local inner classes (a class within a method);

  • anonymous inner classes [17] (a class within a method without a name).

    [17] This type of Java inner class is very commonly used in AWT and Swing.

The first two are inner classes declared at class scope, while the others are inner classes declared at method scope. C# only supports the second type of inner classes (nested ...

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