Keywords In JAVA With Examples

Keywords in JAVA are predefined list of keywords which has a specific meaning and cannot be used in the Java programming language as an identifier, such as the name of a variable, method, class, function, or label. JAVA has total of 50 such keywords.

List of Keywords In JAVA:

Abstract, Continue, For, New, switch, assert, default, goto, package, synchronized, boolean, do, if, private, this, break, double, implements, protected, throw, byte, else, import, public, throws, case, enum****, instanceof, return, transient, catch extends, int, short, try, char, final, interface, static, void, class, finally, long, strictfp**, volatile, const*, float, native, super and while

Keywords Explanation With Examples:

As we said predefined keywords cannot be used in the JAVA language as an identifier. Lets try to create a variable name while:

int while;

You will get Sytax error “while”, invalid VariableDeclarator. So above keywords cannot be used as an identifier and that is also the reason why they are also called as reserved word or reserved identifier.

Leave a Reply

Your email address will not be published. Required fields are marked *