Reserved keywords in java

Reserved keywords cannot be used as names for variables, classes, methods, or any other identifiers in a Java program.



In Java, some identifiers are reserved to associate some functionality or meaning such types of reserved identifiers are called reserved words.

Reserved keywords Java


Reserved  words for data  types:

  • byte
  • short
  • int
  • long
  • float
  • double
  • char
  • boolean

Reserved words for flow control:

  • if
  • else
  • switch
  • case
  • default
  • for
  • do
  • while
  • break
  • continue
  • return

Reserved Keywords  for modifiers:

  • public
  • private
  • protected
  • static
  • final
  • abstract
  • synchronized
  • native
  • transient
  • Volatile
  • strictfp

 
Reserved Keywords  for exception handling:

  • try
  • catch
  • finally
  • throw
  • throws
  • assert

 Class-related Reserved keywords:

  • class
  • package
  • import
  • extends
  • implements
  • interface

 

Object-related Reserved keywords:

  • new
  • instance of
  • super
  • this

 

Void return type Reserved keyword:

  • void

 

Unused keywords:

  • goto: Create several problems in old languages and hence it is banned in Java.
  • Const: Use final instead of this.

By mistake, if we are using these keywords in our program we will get compile time error.


Reserved literals keyword:

  • true  -values for the boolean data type.
  • false -values for the boolean data type.
  • null -the default value for an object reference.


Enum:

This keyword is introduced in 1.5v to define a group of named constants.

Example:

enum Days {

MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;

}


Note: All reserved words in java contain only lowercase alphabet symbols. 

Read Health Related Tips: Daily Health Tips

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.