I found this while reading about programmatic configuration of servlets:
ServletRegistration.Dynamic addServlet(String name, String servletClass)
This one: ServletRegistration.Dynamic baffles my core Java syntax knowledge. What does it mean?
I found this while reading about programmatic configuration of servlets:
ServletRegistration.Dynamic addServlet(String name, String servletClass)
This one: ServletRegistration.Dynamic baffles my core Java syntax knowledge. What does it mean?
That is a static nested interface. It has been defined in the source code as
public interface ServletRegistration {
public static interface Dynamic {
// ..
}
// ..
}
Read more about Nested Classes. The concepts apply to interfaces as well.
Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes.
Also, take a look at this SO link: Java inner class and static nested class
Look at the documentation on ServletRegistration
There you can see Dynamic is a nested class
As per Java Docs, ServletRegistration.Dynamic
is a sub interface of Interface ServletRegistration
public static interface ServletRegistration.Dynamic extends ServletRegistration, Registration.Dynamic
What does it mean?
It means that return type of addServlet
is ServletRegistration.Dynamic
And how is this possible?
This was possible but ServletRegistration.Dynamic
is a sub-interface.