I m new to programming .Can anybody tell me where do we use Nested Class in piratical(i dont need the code )? and Why do we use it with out using regular class Plz explain me

Hi finito, I think the OP meant more something like this

Hi finito, I think the OP meant more something like this

Thanxx ddanbe, your codes are correct but i want to know where i use the nested classes in real word . I know how to write nested class , but i dont know where,what is the most suitable time to use, why nested class ,why it is important to use them, plz explain me

Hi ddanbe, thanks for pointing out my error, I had completely forgotten what a Nested class is. Thanks for the refresh. but OP wants a practical application for it.

MrBlack from what I remember it's about Logic and subdivisions.

It is not necessary to use Nested Classes, It is just to make it easier to read the code and understand the logic behind the code.

Hmm.
Sort of like how Animals are subdivided into Groups and Sub Groups and Sub groups of Sub Groups.

Insects, Mammals, Fish, etc
Dogs, Cats, Mice, Humans, etc.
Pekenise, Rottweilers, Labrador, etc.
Labrador-Golden Retriever Mix, etc
1/4 Labrador-3/4 Pekenise Mix
and so on

Nested classes are intended to be used by the surrounding class and can be made private. A class as such cannot be private. I never have found a really practical use for nested classes.

Thanks a lot finito ,Thanks a lot ddanbe, Your examples are really help me to understand these things, Thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.