-
Java (
http://www.daniweb.com/forums/forum9.html)
| painless | Jul 2nd, 2009 9:40 am | |
| What is the Use of Inner classes Can any one justify the use of inner classes with example(if possible) |
| Ramy Mahrous | Jul 2nd, 2009 10:17 am | |
| Re: What is the Use of Inner classes To be visible to just parent class.
namespace Example
{
class Parent
{
void Method()
{
Child c = new Child();//No error
}
class Child
{
}
}
class Painless
{
void Method()
{
Child c = new Child();//error
}
}
} |
| JamesCherrill | Jul 2nd, 2009 10:18 am | |
| Re: What is the Use of Inner classes Sometimes you need an instance of a class - eg as a Listener for a Swing Event,, or a Runnable for a Thread - and these are most conveniently and compactly created locally as inner classes, often anonymous inner classes. |
| BestJewSinceJC | Jul 2nd, 2009 1:34 pm | |
| Re: What is the Use of Inner classes And inner classes can provide specific functionality for their parent classes. There are relevant examples in the Sun tutorials on inner classes. |
| All times are GMT -4. The time now is 12:21 am. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC