what is a token?
A token is nothing but smallest part of the program or individual part of the statement
Without tokens ,statement is not possible.
Tokens are of 6 types
- Identifiers
- Literals
- Comment symbols
- Separator
- Operator
- keyword
Identifier
Identifier is nothing but to identify the corresponding member, without identifier we cannot able to callback, corresponding member.
Java supported 5 types of
- Package name
- Object name
- Class name
- Function name
- Variable name
Literal
Literal is a value which is possible to modify ,where as constant also one type of literal, which does not support modifications.
5 types of literals
Integer literal Ex: 10
Float literal Ex: 10.55
Boolean literal Ex : True/False
Character literal Ex : 'a'
String literal Ex : "kirran" .
Comment symbols: Java has 3 types of comment symbols
Single line -------------- C /* and */
Multiple lines --------------C++ is //
- Multiline/paragraph for C,C++, Java is /* and */
HTML comment /**……………*/
Keywords
A keyword is a word ,whose meaning is already being explained to compiler.
Keywords are reserved words , do not use them as word.
abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while
* not used
** added in 1.2
*** added in 1.4
**** added in 5.0
Operators
An operator performs a particular operation on the operands it is applied on
Types of operators
------Simple Assignment Operator
= Simple assignment operator
------Arithmetic Operators
+ Additive operator (also used
for String concatenation)
- Subtraction operator
* Multiplication operator
/ Division operator
% Remainder operator
-------Unary Operators
+ Unary plus operator; indicates
positive value (numbers are
positive without this, however)
- Unary minus operator; negates
an expression
++ Increment operator; increments
a value by 1
-- Decrement operator; decrements
a value by 1
! Logical complement operator;
inverts the value of a boolean
--------Equality and Relational Operators
== Equal to
!= Not equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
-------Conditional Operators
&& Conditional-AND
|| Conditional-OR
?: Ternary (shorthand for
if-then-else statement)
--------Type Comparison Operator
instanceof Compares an object to
a specified type
----------Bitwise and Bit Shift Operators
~ Unary bitwise complement
<< Signed left shift
>> Signed right shift
>>> Unsigned right shift
& Bitwise AND
^ Bitwise exclusive OR
| Bitwise inclusive OR
Statements
A Java statement is the smallest unit that is a complete instruction.
Statements must end with a semi-colon.
Statements generally contain expressions (expressions have a value)
One of the simplest is the Assignment Statement
<variable> = <expression>;
For Example:
int height; height = 34;
No comments:
Post a Comment