Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

real time example for inner class and static inner classes.

 
pardhava krishna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can you please let me know when we choose inner classes over normal classes.And even when we opt for static inner classes with some real time example.This will help me a lot.

Regards,
Pardhu
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this might help you webpage
 
Henry Wong
author
Marshal
Pie
Posts: 20996
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Also, I assume that you mean "real life" example, and not "real time" example. As a real time example would probably refer to an example using real-time java.

Henry
 
pardhava krishna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks of the prompt response.

yes i would mean situation or a requirement where do we go for inner classes.

Regards,
Pardhu
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about a LinkedList and Node inside a LinkedList. You can have the Node as a private inner class of the LinkedList class.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Also, I assume that you mean "real life" example, and not "real time" example. As a real time example would probably refer to an example using real-time java.
Henry


Henry, could you please give a good book on real - time java?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think real-time actually means?
 
pardhava krishna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry if I am confusing you with the word real-time.actually i would like to know where we go for inner classes with out a seperate class,with an example. What are the disadvantages if we choose seperate classes instead of inner classes in that example .

Regards,
Pardhu
 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've to at times felt that..whatever you do with an inner class, you can very well do with a separate final class(so that no one else inherits and uses it) and instantiate it inside your class.
Is there any other situation where we are forced to create an inner class(i think, this is what pardhava krishna meant by real-time), rather than a separate class outside?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://download-llnw.oracle.com/javase/tutorial/java/javaOO/nested.html
look at the sub-headline *Why Use Nested Classes?*
<edit>
the good example is *LinkedList* source code as campbell mentioned.
</edit>

hth
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Real-time means happening at the same time, so a real-time program must respond immediately to any input. Real-time programs are often used for controlling machinery, where for example the power must be turned on and off at exactly the right time.
 
pardhava krishna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Yes ,What Ranch Hand is asking was my actual question.

Regards,
Pardhu
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:How about a LinkedList and Node inside a LinkedList. You can have the Node as a private inner class of the LinkedList class.


thanks Campbell this example makes my concept strong too
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic