Forums Register Login

Real time application of Inner Class

+Pie Number of slices to send: Send
Hi all,
i need a real time application or implementation to understand the property of inner class. i read and got the semantics of inner class by using MyOuterClass and MyInnerClass. But i need some real time scenario where we can implement Inner Class to represent that Entity.
+Pie Number of slices to send: Send
Do you mean "real time" as in real-time computing or "real world", meaning a concrete example?
If you mean the latter, I once used an inner class to implement a linked list. Linked lists are made up of node which contain a data reference and pointers to other nodes in the list. Since the user of the linked list is interested in the data in the list and not the implementation of the list itself, I made the node class an inner class.
+Pie Number of slices to send: Send
hi joe i am meant to say real world.

can i say that the output of certain process will be a member of the outer class and the thing or logic which brings out will be a inner class..
+Pie Number of slices to send: Send
You can declare anything to be an inner class. The question remains: should it BE an inner class? I think you have to clear up the relationship between your classes before you can answer that. Have a look at the Java Tutorial chapter on Nested Classes for some more examples.
1
+Pie Number of slices to send: Send
You would use an inner class only if you are dealing with an object that has no use or meaning outside of its outer class and is complex enough to merit its own objectification (for a lack of a better term). It's difficult to find a general example because it really depends on your application, but perhaps an Address class could have a PhoneNumbers inner class which holds all the phone numbers associated with the address and implements some extra functionality, like returning the best phone number, the most used one and whether they are all in the same area code. You need a class to do all the extra nifty things, but you don't really need it in a separate class, since you do not need (or want) to deal with phone numbers outside of the context of an Address.
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2632 times.
Similar Threads
in what situations we will use anonymous class
Reg Inner Class
Help with inner classes.
about inner class
Example and use of Anonymous Inner Class in j2ee projects.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:24:40.