JAVA Tokens
JAVA Tokens
In Java, the program contains classes and methods. Further, the methods
contain the expressions and statements required to perform a specific
operation. These statements and expressions are made up of tokens. In
other words, we can say that the expression and statement is a set
of tokens. The tokens are the small building blocks of a Java program that
are meaningful to the Java compiler. Further, these two components
contain variables, constants, and operators. In this section, we will
discuss what is tokens in Java.
The Java compiler translates these tokens into Java bytecode. Further,
these bytecodes are executed inside the interpreted Java environment.
Types of Tokens
Java token includes the following:
o Keywords
o Identifiers
o Literals
o Operators
o Separators
o Comments
w
01. 02. boolean 03. byte 04. break 05. class
abstract
31. public 32. return 33. short 34. static 35. super
46. assert 47. const 48. enum 49. goto 50. strictfp
1. PhoneNumber
2.
3. PRICE
4. radius
5. a
6. a1
7. _phonenumber
8. $circumference
9. jagged_array
10. 12radius //invalid
Literals: In programming literal is a notation that represents a fixed value
(constant) in the source code. It can be categorized as an integer literal,
string literal, Boolean literal, etc. It is defined by the programmer. Once it
has been defined cannot be changed. Java provides five types of literals
are as follows:
o Integer
o Floating Point
o Character
o String
o Boolean
Literal Type
23 int
9.86 double
"javatpoint" String
o Arithmetic Operators
o Assignment Operators
o Relational Operators
o Unary Operators
o Logical Operators
o Ternary Operators
o Bitwise Operators
o Shift Operators
Operator Symbols
Arithmetic +,-,/,*,%
Unary ++ , - - , !
Assignment = , += , -= , *= , /= , %= , ^=
Logical && , ||
Bitwise &,|,^,~
1. separator <= ; | , | . | ( | ) | { | } | [ | ]
Note that the first three separators (; , and .) are tokens that separate other tokens, and
the last six (3 pairs of braces) separators are also known as delimiters. For example,
Math.pow(9, 3); contains nine tokens.