Home arrow static arrow Java Programming [Archive] - INNEER CLASS
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - INNEER CLASS
This topic has 7 replies on 1 page.

Posts:339
Registered: 4/12/04
INNEER CLASS  
Jun 14, 2004 10:22 PM



 
what is the use of inner class.
pLEASE
 

Posts:1,995
Registered: 12/10/00
Re: INNEER CLASS  
Jun 14, 2004 10:48 PM (reply 1 of 7)



 
Did you try a [url http://onesearch.sun.com/search/developers/index.jsp?col=devforums&qp_name=Java+Programming&qp=forum%3A31&qt=%22inner+class%22]search[/url]?
Did you check the tutorial? It's good practice to do these things before posting.

Mike
 

Posts:6,147
Registered: 11/9/00
Re: INNEER CLASS  
Jun 14, 2004 11:21 PM (reply 2 of 7)



 
There are lots of reasons for using an inner class. The simplest is it's one less java file to clutter your editor with. If one class is only used inside the methods of another then making it an inner class is sensible.

Inner classes are also useful as various kinds of delegate because, unless they are static, they have access to the fields of the outer class. So, for example, if you have a class that houses some kind of collection of data you may want methods that return an iterator or enumerator to allow other classes to walk through the collection. It makes sense to implement those iterators as inner (often anonymous) classes. Or you may want, say, to add different ActionListener s to different buttons. A small inner class which implements ActionListener can invoke the appropriate method in your main class.

You often use them for structured data of which a class has multiple instances.
 

Posts:2,275
Registered: 10/18/03
Re: INNEER CLASS  
Jun 15, 2004 3:04 AM (reply 3 of 7)



 

Modularisation
Functionality
Readability
Simplicity (particularly for anonymous classes)
Reuse
Access control
Encapsulation

- Is this enough?
 

Posts:3,258
Registered: 00-08-28
Re: INNEER CLASS  
Jun 15, 2004 1:39 PM (reply 4 of 7)



 
[url http://www.javaworld.com/javaworld/javaqa/2000-03/02-qa-innerclass.html] uses of inner classes [/url]
 

Posts:19,725
Registered: 9/26/01
Re: INNEER CLASS  
Jun 15, 2004 1:43 PM (reply 5 of 7)



 
What is this? Taking an exam/homework and posting each question for others to answer for you?
http://forum.java.sun.com/thread.jsp?thread=530604&forum=31&message=2554819
http://forum.java.sun.com/thread.jsp?thread=530721&forum=33&message=2555585
http://forum.java.sun.com/thread.jsp?thread=530603&forum=33&message=2554814
 

Posts:3,258
Registered: 00-08-28
Re: INNEER CLASS  
Jun 15, 2004 1:54 PM (reply 6 of 7)



 
come on OK. If he is learning something this way its good.
 

Posts:6,750
Registered: 1/25/04
Re: INNEER CLASS  
Jun 15, 2004 1:55 PM (reply 7 of 7)



 
Yes, but what if he's not? :-)
 
This topic has 7 replies on 1 page.