As we use “default” keyword as a access specifier, and it can be used in switch statements as well with complete different purpose, So i was curious that is there any other keywords in java which can be used in more then one purposes
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
defaultcan be used both in a switch and as a default value in an annotation (as pointed out by Bozho)finalmeans “can’t be derived from / overridden” and “is read-only” which are two different – but related – meanings (as pointed out by Jon)extendscan be used both to specify the supertype of a class and can be used in wildcards and type variables to put a constraint (related but not exactly the same) (List<? extends Foo>)supercan be used to specify to something in a superclass of the current class, or in a wildcard to put a constraint (List<? super Foo>)staticmeans both “part of the class, not an instance” (for methods, attributes or initializers) and as astatic importclassto declare a class (class Foo {}), or to refer to a class literal (Foo.class) (as answered by ILMTitan)forcan be used in a normal for loop and the “enhanced” for, but that’s more like overloading (as Bozho puts it so nicely) than really having two meanings)