Token in Java is the smallest piece of code, identified by the compiler.
Tokens can be:
- Identifiers
myVariablemyMethodMyClass - Keywords
newclassint - Literals
"a string"'c'53.3 - Operators
>==+ - Separators
;, - Comments
/* a comment */
What tokens are present here?
In this block of code:
int number1 = 2;
int number2 = 3;
// adding 2 + 3
int result = number1 + number2;
number1,number2,resultare identifiers.intis a keyword.2and3are literals.=and+are operators.;is a separator.// adding 2 + 3is a comment.
