Upload
victor-richards
View
215
Download
0
Embed Size (px)
Citation preview
Ajmer Singh PGT(IP)
Programming Fundamentals
Ajmer Singh PGT(IP)
Java Character Set• Character set is a set of valid characters that a language
can recognize . A character represents any letter, digit, or any other sign. Java uses the Unicode character set.
Letters :- A-Z, a-z
Digits :- 0-9 Special Symbols :- Space + - * / ^ \ ( ) [ ] { } = !
= < > . ‘ “ $ , ; : % ! & ? _(underscore) # <= >= @ White Spaces :- Blank spaces, Horizontal tab,
Carriage return, New line, Form feed.
Tokens(Lexical units)The smallest individual unit in a program is known as a
Token or lexical unit.
Types of Tokens :-
KeywordsIdentifiersLiteralsPunctuatorsOperators
Keywords
Keywords are the words that convey a special meaning to the language compiler. These are reserved for special purpose and must not be used as normal identifier names. E.g if, else, int, float, etc.
IdentifiersIdentifiers are names given to different part of the
program by user.
Rules to write identifiers :-1. They must not begin with digits.2. No special symbols are used except
_(underscore) and $ (dollar sign) character3. They must not be a keyword.4. Java is case sensitive language. Upper case
and lower case letters are treated differently. Examples:- myfile , date9_2_7_6
LiteralsLiterals (literals) are data items that are fixed data
values.
Types of Literals :-1. Integer literal
2. Floating literal
3. Character literal
4. String literal
5. Boolean literal
6. Null literal
Integer LiteralInteger literals are whole numbers without any
fractional part.
Three types of Integer literals :-1. Decimal Integer literal
2. Octal Integer literal
3. Hexadecimal Integer literal
Decimal Integer literal
An integer literal consisting of a sequence of digits is taken to be decimal integer literal unless it begins with 0 (digit zero).
Example:- 1296, 5642, 12, +69,- 23,etc.,
Octal Integer literal
A sequence of digits starting with 0(digit zero) is taken to be an octal integer.
Example:-0123, 0456, etc.,
Hexadecimal Integer literal
A sequence of digits preceded by 0x or 0X is taken to be an hexadecimal integer.
Example:- 0x4B6, 0XA43,etc.,
Floating literals
Floating literals are also called as Real literals
Real literals are numbers having fractional parts. These may be written in one of the two forms called fractional form or the exponent form.
Examples:-2.0, 3.5, 8.6, etc.,
Character literals
A Character literal is one character enclosed in single quotes, as in ‘z’.
Examples:- ‘a’, ‘b’, etc.,
String Literals
String literal is a sequence of zero or more characters surrounded by double quotes(“ ”).
Examples:-”a” , “ade”, etc.,
Ajmer Singh PGT(IP)
Punctuators or Separators
The following characters are used as punctuators.
[ ] ( ) { } , ; .
Ajmer Singh PGT(IP)
Operators Operators are symbols that perform some
action. E.g +, -, /, * etc.