Keywords

Keywords are some special names which are reserved by JAVA, We can not use that names to create variables,classes or methods. They have their different meanings. for example “class”, its reserved by JAVA. This keyword is used to create new class but if we try to use that name for our class then its impossible.

for example if we make a class like this example :


class class{
  public static void main(String[] args){
    System.out.println("Hello");
  }
}

and when you try to run this code then you will get below error :

_class.java:1: error: expected_

as shown in below screenshot.

java-keyword

List of Keywords in JAVA :

  1. abstract
  2. assert
  3. boolean
  4. break
  5. byte
  6. case
  7. catch
  8. char
  9. class
  10. const
  11. continue
  12. default
  13. do
  14. double
  15. else
  16. enum
  17. extends
  18. final
  19. finally
  20. float
  21. for
  22. goto
  23. if
  24. implements
  25. import
  26. instanceof
  27. int
  28. interface
  29. long
  30. native
  31. new
  32. package
  33. private
  34. protected
  35. public
  36. return
  37. short
  38. static
  39. strictfp
  40. super
  41. switch
  42. synchronized
  43. this
  44. throw
  45. throws
  46. transient
  47. try
  48. void
  49. volatile
  50. while

here is list by categories :

Category Keywords
Access modifiers private, protected, public
Class, method, variable modifiers abstract, class, extends, final, implements, interface, native, new,static, strictfp, synchronized, transient, volatile
Flow control break, case, continue, default, do, else, for, if, instanceof, return,switch, while
Package control import, package
Primitive types boolean, byte, char, double, float, int, long, short
Error handling assert, catch, finally, throw, throws, try
Enumeration enum
Others super, this, void
Unused const, goto

These are keywords in java, each and every keyword have its special task. for example ‘classkeyword is used to create Classes in java. It is impossible to create Class without using ‘class’ keyword.