A static class can be created inside another class as a nested static class, which will not able to access the non-static data members and methods as well. Whereas, it can able to access the private data members.
class Intellipaat{
static int data=30;
static class InnerIntellipaat{
void msg(){System.out.println("Intellipaat's data is "+data);}
}
public static void main(String args[]){
Intellipaat.InnerIntellipaat obj=new Intellipaat.InnerIntellipaat();
obj.msg();
}
}
I hope this will help.
Want to become a Java Expert? join Java Training now!!