Token and keywords

  • April 27, 2022
  • Java
method overloading and method overriding
Token

The smallest individual unit in a program is known as a token. In fact, every unit that makes a sentence is a token.

Java has the following token:

  • Keywords
  • Identifiers
  • Literals
  • Punctuators
  • Operators
Keywords

Keywords are the words that convey a special meaning to the language compiler. These are reserved for special purposes and must not be used as normal identifier names.

The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers:

abstractdefaultifprivatethis
booleandoimplementsprotectedthrow
breakdoubleimportpublicthrows
byteelseinstanceofreturntransient
caseextendsintshorttry
catchfinalinterfacestaticvoid
charfinallylongstrictfpvolatile
classfloatnativesuperwhile
constfornewswitch
continuegotopackagesynchronized

The keywords const and goto are reserved, even though they are currently not in use. This may allow a Java compiler to produce better error messages if these Java Keywords incorrectly appear in programs.

While true and false might appear to be keywords, they are technically boolean literals. Similarly, while null might appear to be a keyword, it is technically the null literal. Thus true, false and null are not keywords but reserved words.

Note: also read about the Simple Hello World Program

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Leave a Reply

Your email address will not be published. Required fields are marked *