logo
Java Static Inner Classes
Static inner classes
In general in java classes it is not possible to declare any class as a abstract class but is possible to declare inner class as a static modifier.
Declaring the static class inside the another class is called static inner class.
Static inner classes can access only static variables and static methods it does not access the instace variables and instance methods.
Syntax :
class Outer
{
static class Inner
{
};
};
Static inner classes program
class Test 
{ 
static int a=10; 
static int b=20; 
static class Inner 
{ 
int c=30; 
void m1() 
{ 
System.out.println(a); 
System.out.println(b); 
System.out.println(c); 
} 
}; 
public static void main(String[] args) 
{ 
Test o=new Test(); 
Test.Inner i=new Test.Inner(); 
i.m1(); 
} 
};
Output :
10
20
30