java tutorial

Difference between Nested, Inner, Local and Anonymous class in Java

There are two types of nested class in Java, static and non-static, later is also known as Inner class. Main difference between them is that static class is not associated with Outer class instance and you can create its instance without having an Outer class instance, but Inner classes are associated with Outer class instance and cannot be created without them.

There are mainly two types of nested class in Java, static and non-static. Out of these two, static nested class are simply refereed as nested class while non-static nested class are known as Inner class in Java. Inner class is further divided into member class, local Inner class and Anonymous Inner class. Where first one is simply a non static member of the class, second one is declared inside local scope e.g. inside a method or block and third one is special type of class which is implemented at the time of initialization, since it doesn’t have name and it cant be reused its known as Anonymous class.

to read more, see full tutorial

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s