• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

real time example for inner class and static inner classes.

 
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
 
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this might help you webpage
 
author
Posts: 23853
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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
 
Marshal
Posts: 67437
257
  • 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.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure 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
Marshal
Posts: 67437
257
  • 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
 
Ranch Hand
Posts: 276
Netbeans IDE Chrome Java
  • 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?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • 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
Marshal
Posts: 67437
257
  • 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
MyEclipse IDE Python Java
  • 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
 
Ranch Hand
Posts: 240
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"real-time" word is probably given by indian tutors, it refers the real-project(application), so he expects you to answer in context of a real-project unlike you provide examples of 'Animal-dog' classes. Like if questioner is asking about real-time usage of inner class, he means to ask what scenario of a real project would you decide to use inner classes in.
Like if someone asks you to provide real time usage of multithreading, you could answer that you create a new thread to download the file in an app,  
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!