Java has 51 keywords and identifiers that are used to name classes, methods, variables and other program elements. Keywords have special meaning in Java and cannot be used outside of their intended purpose, while identifiers can be any valid name following Java naming conventions. Identifiers must not contain spaces or special characters and are case sensitive. Common conventions include using PascalCase for class names, camelCase for methods and variables, and ALL_CAPS for constants.
Java has 51 keywords and identifiers that are used to name classes, methods, variables and other program elements. Keywords have special meaning in Java and cannot be used outside of their intended purpose, while identifiers can be any valid name following Java naming conventions. Identifiers must not contain spaces or special characters and are case sensitive. Common conventions include using PascalCase for class names, camelCase for methods and variables, and ALL_CAPS for constants.
Java has 51 keywords and identifiers that are used to name classes, methods, variables and other program elements. Keywords have special meaning in Java and cannot be used outside of their intended purpose, while identifiers can be any valid name following Java naming conventions. Identifiers must not contain spaces or special characters and are case sensitive. Common conventions include using PascalCase for class names, camelCase for methods and variables, and ALL_CAPS for constants.
Java Keywords • A Java Keyword is a word in Java with special meaning • Examples: public, class, void, static • Keywords are reserved by the Java language. Meaning you cannot use these outside of their purpose. • Example: You cannot name a method ‘void’
• There are 51 Keywords in Java, 2 of which are not in use
Java Keywords abstract if throws final native continue private case interface super for this enum static while new break instanceof void _ (Underscore) switch double return class assert implements transient finally Other default protected catch long goto throw extends strictfp true package byte int volatile false synchronized else short const null boolean import try float var do public char Java Identifiers • Java Identifiers are names you define for methods, class names, variable names, constant names, package names
• Pretty much anything you are assigning a name to in your program
SUPER_METHOD, myVariable_123 Rules for Identifiers • Can use any upper or lowercase letter or number (a-z, A-Z, 0-9) • Can also use the underscore ‘_’ and dollar sign ‘$’ • Identifiers are case sensitive
• Cannot have spaces or other special characters
• Example: @, %, *, ! <— Not inclusive list! Conventions • Class names should be Pascal Case • Camel case with starting capital • Methods and variables should be Camel Case, with starting lower case
• Constants all upper case separated with underscores
• MY_CONSTANT_NAME • Packages all lower case • Reverse domain name is preferred