Why default specifier is not allowed to specify for any class member in Java? -
the default access specifier of java class member "default". mean when no specifier has specified before member of class, java takes default implicitly. have ever tried put default specifier explicitly before method or variable in class. try once , see.
class demo{ default string name; // valid??? }
i wanted know reason behind it?
default
keyword has nothing access modifiers.
in access modifier's context, absence of specific access modifier called default.
default
keyword's actual usage -
the default keyword can optionally used in switch statement label block of statements executed if no case matches specified value; see switch.
the default keyword can used declare default values in java annotation.
from java 8 onwards, default keyword used specify method in interface provides default implementation of optional method.
Comments
Post a Comment