Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /home/cbsetut9/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php on line 340

Warning: Cannot modify header information - headers already sent by (output started at /home/cbsetut9/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_langs.class.php:340) in /home/cbsetut9/public_html/wp-content/plugins/sg-cachepress/core/Supercacher/Supercacher_Helper.php on line 77
keywords in Java | CodePrime

keywords in Java


Reserved Words in Java

Reserved words are those words that a programmer cannot use for identifier name because that has been reserved by the language to perform different operations.

Reserved words consist of:

  • Used keywords : 48 keywords currently in use.
  • Unused keywods : 2 keywords(const, goto) not currently in use in the language.
  • Some literals : 3 literal values(true, false, null).

The exhaustive list of keywords in Java programming language is:
  1. abstract : Used to implement an abstraction. Like classes and methods that can be implemented later.

  2. assert : It is used to place a predicate that the programmar thinks is true at that position in the program. If the assertion evaluates to false, the execution aborts.

  3. boolean : A data type that can be either true or false.

  4. break : A control statement to break out of the loop.

  5. byte : A data type which is 8-bit wide.

  6. case : Used inside switch statement to mark a code block.

  7. catch : Used to catch specific type of exceptions thrown by try statements.

  8. char : A 16-bit wide data-type to hold unsigned characters.

  9. class : Used to provide definition for new type of objects.

  10. continue : A control statement that sends the control to the end of a loop body.

  11. default : An optional statement that defines a default block of code inside switch statement.

  12. do : Used to signify the beginning of a do-while loop.

  13. double : A 64-bit wide data type to hold double precision signed floating-point numbers.

  14. else : Used to define alternative code block if the condition inside if-statement fails.

  15. enum : Used to declare enumerated type.

  16. extends : Used to specify the superclass for a class.

  17. final : A final class cannot be inherited, a final method cannot be overridden and a final variable  cannot be re-assigned a value.

  18. finally : Defines a block of code after try-catch which is always executed.

  19. float : A 32-bit wide data type to hold single precision signed floating point numbers.

  20. for : Used to create a for loop.

  21. if : Used to define a code block which is executed if some condition is true.

  22. implements : Used to specify one or more interfaces that a class implements.

  23. import : Used to denote the packages and classes that have to be brought to the current scope.

  24. instanceof : Used to test if an object is an instance of a class or implements an interface.

  25. int : A 32-bit wide data type to hold signed integers.

  26. interface : Used to define a code block containing methods which will be implemented later.

  27. long : A 64-bit wide data type to hold signed integers.

  28. native : Used to specify that a method is not implemented in Java language but some other language like C, C++.

  29. new : Used to create objects of a class or to create new arrays.

  30. package : Used to create a package which is a collection of similar classes and interfaces.

  31. private : An access modifier. A private member of a class is visible only inside the class.

  32. protected : An access modifier. A protected member of a class is accessible in current package and subclasses outside the package.

  33. public : An access modifier. A public member is accessible from anywhere.

  34. return : Used to return some value from a method or to terminate the execution of a method.

  35. short : A 16-bit wide data type to hold signed integers.

  36. static : Used to declare static variables, static methods or static nested classes.

  37. strictfp : Used to restrict the precision and rounding of floating point operations to improve portability.

  38. super : Used to refer members of a superclass or to call its constructors.

  39. switch : Used to define a multiway branch statement.

  40. synchronized : Used to acquire mutex lock in a multithreaded program.

  41. this : During class design, it is used to refer current object of a class or to call the constructor of the current class.

  42. throw : Used to throw an exception.

  43. throws : Used to denote which exceptions might be thrown by a method.

  44. transient : Used to mark that an instance variable is not a part of the persistent state of an object.

  45. try : Used to define a block of code that will be tested for exceptions.

  46. void : Used to denote that a method returns nothing.

  47. volatile : Used to denote that a variable may change asynchronously.

  48. while : Used to define the while loop.

Unused Keywords
  1. const : A reserved keyword but not currently in use by the Java programming language.
  2. goto : A reserved keyword but not currently in use by the Java programming language.

Reserved words for literals

Although they may appear like keywords, they are literals actually.

  1. true : A boolean literal value used in affirmative sense.
  2. false : A boolean literal value used in negative sense.
  3. null : A reference literal value used to denote that a reference variable refers nothing.