Explicit is what is written in the source code. So, if something is declared as a public final class , it means that the class is clearly final.
Implicit - this is something that is not written in the source code, but that in the context of a certain construction or based on language rules, the element behaves as it was declared with the specified modifier.
For example, the enum keyword in the enum SomeEnum { } calls SomeEnum as final , because language rules SomeEnum it. Its effect matches that of the final keyword.
An example of an anonymous class that is implicitly final is the lack of a language construct for overriding an anonymous class. Therefore, it behaves as if it were final . I think the word effective is better here.
However, you cannot make assumptions based on how things reflect. Consider the following snippet:
public class Test { interface SomeInterface { } abstract interface SomeAbstractInterface { } static abstract class SomeAbstractClass { } enum SomeEnum { } public static void main(String arg[]) { System.out.println(Modifier.toString(SomeInterface.class.getModifiers())); System.out.println(Modifier.toString(SomeAbstractInterface.class.getModifiers())); System.out.println(Modifier.toString(SomeAbstractClass.class.getModifiers())); System.out.println(Modifier.toString(SomeEnum.class.getModifiers())); } }
The result is the following:
abstract static interface abstract static interface abstract static static final
Both interface and abstract interface are considered an abstract interface. They are also considered static when reflected. Apparently, in the process of parsing and compiling the Java source code, some modifiers can be removed or added.
Mc emperor
source share