Thursday, April 10, 2014

What is Inner Class ?

An inner class is a class defined within another class. Other than a few restrictions, mentioned in the text that follows, they are declared like regular classes.

public class MyClass {
String x;
class MyInnerClass {
String y;
void doSomething() {
// cannot access x from here!
}
}


Inner classes are always static, so the static keyword is not permitted.They can’t reference variables in their containing class.Additionally, inner classes cannot contain other inner classes and cannot contain static variables.

1 comments:

Post a Comment

 
| ,