I am trying to create static class in Java Web Application using eclipse. but it says
Illegal modifier for the class ClassName; only public, abstract & final are permitted
can we create static class in web application ? if no why ?
I am trying to create static class in Java Web Application using eclipse. but it says
Illegal modifier for the class ClassName; only public, abstract & final are permitted
can we create static class in web application ? if no why ?
Static class
you can create in general only
as nested class
in another class. This has nothing to do with Web-Application. It has a general validity in Java
.
Each compilation unit should contain a public or default (non-static) class. Then within it you can declare static nested classes
.
Only inner classes can be made as static. That means except inner class you can not create static class
A static class is, in practice, nothing else than a standard non-inner class declared in another class.
In other words, your app web application has nothing to do with classes being declared as static or not.
Outer class cannot be static. Only nested class can be static. For example below is possible
class OuterClass {
static class StaticNestedClass {
...
}
}
But not
static class OuterClass {
...
}