Java Reserved Words
In java, some identifiers are reserved to associate some functionality or meaning such type of reserved identifiers is called reserved words.
> Reserved words for data types (8)
- byte
- short
- int
- long
- float
- char
- double
- boolean
> Reserved words for flow control (11)
- if
- else
- switch
- case
- default
- for
- do
- while
- break
- continue
- return
- public
- private
- protected
- static
- final
- abstract
- synchronized
- native
- strictfp (1.2 version)
- transient
- volatile
> Keywords for exception handling (6)
- try
- catch
- finally
- throw
- throws
- assert (1.4 version)
> Class related keywords (6)
- class
- package
- import
- extends
- implements
- interface
> Object related keywords (4)
- new
- super
- instanceof
- this
> Void return type keywords:
If a method won't return anything compulsory that method should be declared with the void return type in java but it is optional in C++
- 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 a compile-time error.
> Reserved literals :
- true values for boolean data type
- false
- null default value for object reference
Comments
Post a Comment