Wednesday, 26 June 2013

List of Keywords in Java

Hi welcome to the Java session. Today we are going to see the list of keywords available in Java.

We already know that keywords are reserved words which are having special meaning to the Java language. Hence we are not allowed to use keywords to name a variable, method or class name etc. A total of 50 reserved words are there in Java.

The list of keywords are:

  1. abstract
  2. assert (This is added in JDK 1.4)
  3. boolean
  4. break
  5. byte
  6. case
  7. catch
  8. char
  9. class
  10. const (This is not used)
  11. continue
  12. default
  13. do
  14. double
  15. else
  16. enum (This is added in JDK 1.5)
  17. extends
  18. final
  19. finally
  20. float
  21. for
  22. goto (This is not used)
  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 (This is added in JDK 1.2)
  40. super
  41. switch
  42. synchronized
  43. this
  44. throw
  45. throws
  46. transient
  47. try
  48. void
  49. volatile
  50. while

Apart from the above keywords true, false and null might look like keywords, but actually they are not keywords. Still these are not allowed to name a variable.

Do remember that main is not a keyword in Java. That means main can be used for naming a variable. Of course it's a bad programming practice!

All these keywords will be covered in our tutorial. Hope the today session is useful to you. 

No comments:

Post a Comment