Java Tokens

17 Feb, 2021
A token is the smallest element of a program that is meaningful to the compiler. Tokens can be classified as follows:
KeywordsIdentifiersConstantsSpecial SymbolsOperators
Keywords
Identifiers
Constants
Special Symbols
Operators
Keyword: Keywords are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed. Java language supports following keywords:
abstract     assert      boolean      
break        byte        case
catch        char        class        
const        continue    default
do           double      else         
enum         exports     extends
final        finally     float        
for          goto        if
implements   import      instanceof   
int          interface   long
module       native      new          
open         opens       package
private      protected   provides     
public       requires    return
short        static      strictfp     
super        switch      synchronized
this         throw       throws       
to           transient   transitive
try          uses        void         
volatile     while       with  
Identifiers: Identifiers are used as the general terminology for naming of variables, functions and arrays. These are user-defined names consisting of an arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Once declared, you can use the identifier in later program statements to refer to the associated value. A special kind of identifier, called a statement label, can be used in goto statements.Examples of valid identifiers :MyVariable
MYVARIABLE
myvariable
x
i
x1
i1
_myvariable
$myvariable
sum_of_array
geeks123Examples of invalid identifiers :My Variable  // contains a space
123geeks   // Begins with a digit
a+c // plus sign is not an alphanumeric character
variable-2 // hyphen is not an alphanumeric character
sum_&_difference // ampersand is not an alphanumeric character
Constants/Literals: Constants are also like normal variables. But, the only difference is, their values can not be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals.Constants may belong to any of the data type.Syntax:final data_type variable_name;Special Symbols: The following special symbols are used in Java having some special meaning and thus, cannot be used for some other purpose.[] () {}, ; * =Brackets[]: Opening and closing brackets are used as array element reference. These indicate single and multidimensional subscripts.Parentheses(): These special symbols are used to indicate function calls and function parameters.Braces{}: These opening and ending curly braces marks the start and end of a block of code containing more than one executable statement.comma (, ): It is used to separate more than one statements like for separating parameters in function calls.semi colon : It is an operator that essentially invokes something called an initialization list.asterick (*): It is used to create pointer variable.assignment operator: It is used to assign values.Operators: Java provides many types of operators which can be used according to the need. They are classified based on the functionality they provide. Some of the types are-Arithmetic OperatorsUnary OperatorsAssignment OperatorRelational OperatorsLogical OperatorsTernary OperatorBitwise OperatorsShift Operatorsinstance of operatorPrecedence and Associativity
Keyword: Keywords are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed. Java language supports following keywords:
abstract     assert      boolean      
break        byte        case
catch        char        class        
const        continue    default
do           double      else         
enum         exports     extends
final        finally     float        
for          goto        if
implements   import      instanceof   
int          interface   long
module       native      new          
open         opens       package
private      protected   provides     
public       requires    return
short        static      strictfp     
super        switch      synchronized
this         throw       throws       
to           transient   transitive
try          uses        void         
volatile     while       with  
Identifiers: Identifiers are used as the general terminology for naming of variables, functions and arrays. These are user-defined names consisting of an arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Once declared, you can use the identifier in later program statements to refer to the associated value. A special kind of identifier, called a statement label, can be used in goto statements.Examples of valid identifiers :MyVariable
MYVARIABLE
myvariable
x
i
x1
i1
_myvariable
$myvariable
sum_of_array
geeks123Examples of invalid identifiers :My Variable  // contains a space
123geeks   // Begins with a digit
a+c // plus sign is not an alphanumeric character
variable-2 // hyphen is not an alphanumeric character
sum_&_difference // ampersand is not an alphanumeric character
Constants/Literals: Constants are also like normal variables. But, the only difference is, their values can not be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals.Constants may belong to any of the data type.Syntax:final data_type variable_name;Special Symbols: The following special symbols are used in Java having some special meaning and thus, cannot be used for some other purpose.[] () {}, ; * =Brackets[]: Opening and closing brackets are used as array element reference. These indicate single and multidimensional subscripts.Parentheses(): These special symbols are used to indicate function calls and function parameters.Braces{}: These opening and ending curly braces marks the start and end of a block of code containing more than one executable statement.comma (, ): It is used to separate more than one statements like for separating parameters in function calls.semi colon : It is an operator that essentially invokes something called an initialization list.asterick (*): It is used to create pointer variable.assignment operator: It is used to assign values.Operators: Java provides many types of operators which can be used according to the need. They are classified based on the functionality they provide. Some of the types are-Arithmetic OperatorsUnary OperatorsAssignment OperatorRelational OperatorsLogical OperatorsTernary OperatorBitwise OperatorsShift Operatorsinstance of operatorPrecedence and Associativity
Keyword: Keywords are pre-defined or reserved words in a programming language. Each keyword is meant to perform a specific function in a program. Since keywords are referred names for a compiler, they can’t be used as variable names because by doing so, we are trying to assign a new meaning to the keyword which is not allowed. Java language supports following keywords:
abstract     assert      boolean      
break        byte        case
catch        char        class        
const        continue    default
do           double      else         
enum         exports     extends
final        finally     float        
for          goto        if
implements   import      instanceof   
int          interface   long
module       native      new          
open         opens       package
private      protected   provides     
public       requires    return
short        static      strictfp     
super        switch      synchronized
this         throw       throws       
to           transient   transitive
try          uses        void         
volatile     while       with  


abstract     assert      boolean      
break        byte        case
catch        char        class        
const        continue    default
do           double      else         
enum         exports     extends
final        finally     float        
for          goto        if
implements   import      instanceof   
int          interface   long
module       native      new          
open         opens       package
private      protected   provides     
public       requires    return
short        static      strictfp     
super        switch      synchronized
this         throw       throws       
to           transient   transitive
try          uses        void         
volatile     while       with  

Identifiers: Identifiers are used as the general terminology for naming of variables, functions and arrays. These are user-defined names consisting of an arbitrarily long sequence of letters and digits with either a letter or the underscore(_) as a first character. Identifier names must differ in spelling and case from any keywords. You cannot use keywords as identifiers; they are reserved for special use. Once declared, you can use the identifier in later program statements to refer to the associated value. A special kind of identifier, called a statement label, can be used in goto statements.Examples of valid identifiers :MyVariable
MYVARIABLE
myvariable
x
i
x1
i1
_myvariable
$myvariable
sum_of_array
geeks123Examples of invalid identifiers :My Variable  // contains a space
123geeks   // Begins with a digit
a+c // plus sign is not an alphanumeric character
variable-2 // hyphen is not an alphanumeric character
sum_&_difference // ampersand is not an alphanumeric character

Examples of valid identifiers :
MyVariable
MYVARIABLE
myvariable
x
i
x1
i1
_myvariable
$myvariable
sum_of_array
geeks123
Examples of invalid identifiers :
My Variable  // contains a space
123geeks   // Begins with a digit
a+c // plus sign is not an alphanumeric character
variable-2 // hyphen is not an alphanumeric character
sum_&_difference // ampersand is not an alphanumeric character

Constants/Literals: Constants are also like normal variables. But, the only difference is, their values can not be modified by the program once they are defined. Constants refer to fixed values. They are also called as literals.Constants may belong to any of the data type.Syntax:final data_type variable_name;
Constants may belong to any of the data type.Syntax:
final data_type variable_name;
Special Symbols: The following special symbols are used in Java having some special meaning and thus, cannot be used for some other purpose.[] () {}, ; * =Brackets[]: Opening and closing brackets are used as array element reference. These indicate single and multidimensional subscripts.Parentheses(): These special symbols are used to indicate function calls and function parameters.Braces{}: These opening and ending curly braces marks the start and end of a block of code containing more than one executable statement.comma (, ): It is used to separate more than one statements like for separating parameters in function calls.semi colon : It is an operator that essentially invokes something called an initialization list.asterick (*): It is used to create pointer variable.assignment operator: It is used to assign values.
[] () {}, ; * =
Brackets[]: Opening and closing brackets are used as array element reference. These indicate single and multidimensional subscripts.
Parentheses(): These special symbols are used to indicate function calls and function parameters.
Braces{}: These opening and ending curly braces marks the start and end of a block of code containing more than one executable statement.
comma (, ): It is used to separate more than one statements like for separating parameters in function calls.
semi colon : It is an operator that essentially invokes something called an initialization list.
asterick (*): It is used to create pointer variable.
assignment operator: It is used to assign values.
Operators: Java provides many types of operators which can be used according to the need. They are classified based on the functionality they provide. Some of the types are-Arithmetic OperatorsUnary OperatorsAssignment OperatorRelational OperatorsLogical OperatorsTernary OperatorBitwise OperatorsShift Operatorsinstance of operatorPrecedence and Associativity
Arithmetic OperatorsUnary OperatorsAssignment OperatorRelational OperatorsLogical OperatorsTernary OperatorBitwise OperatorsShift Operatorsinstance of operatorPrecedence and Associativity
Arithmetic Operators
Unary Operators
Assignment Operator
Relational Operators
Logical Operators
Ternary Operator
Bitwise Operators
Shift Operators
instance of operator
Precedence and Associativity
1. Identifiers and Tokens in Java (Core Java) | GeeksforGeeks - YouTubeGeeksforGeeks529K subscribers1. Identifiers and Tokens in Java (Core Java) | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0010:56 / 13:24•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=W_6zSjdwR7c" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
java-basics
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Java Programming Examples
Strings in Java
Differences between JDK, JRE and JVM
Abstraction in Java