# Java || Identifiers # Literals # Separators # Operators
IDENTIFIER UES IN JAVA
Identifiers refers to the names of variables, arrays, class,methods etc. created by the user.
The rules for identifier are :
1. An identifier may consists of letters(A-Z,a-z), digits(0-9), underscore(_) and dollar sign ($).
2. Blank spaces( ) are not allowed.
3. The first character must be a letter(A-Z,a-z), underscore(_) or dollar sign($).
4. Keywords or Reserved words are not allowed here.
Both upper case(A-Z) and lower case(a-z) letters are allowed and are considered to distinguishable. e.g. the identifier SUM is not same as sum or Sum
- The following are valid identifiers
area Average
sum John
table1 distance
Total
- The following are invalid identifiers:
Ram Kumar
- Blank spaces are not allowed
char
- char is a keyword.
8th
- The first character cannot be a number.
Literals or Constants
- A literal is a fixed value that remains unchanged during the execution of a program.
Boolean Literals
Char set Literals
Int Literals
*Integer Literals
An integer literal refer to a sequence of digits without decimal point. There are three type of integer literals, namely, decimal, octal and hexadecimal.
(a) Decimal integers literal consists set of digits 0- 9.
Default sign is positive.
E.g. Valid decimal integer literals
18 ,39,8752
E.g. not valid integer literais
28.0 contains a decimal point
12,250 contains a comma
(b) An octal integer literal consists any combination of digits from 0 to 7 and
it should begin with a 0.
E.g Valid octal integer constants
023,076
(c) A hexadecimal integer literals consists of any combination of digits from 0 through 9 or alphabets A through F with a leading Ox or OX
E.g. valid hexadecimal integer literals
0x5,0X7AB,0x6F
Floating point Literals
Floating point literals are also called real literals. A floating point literal is a number that contains either a decimal point or an exponent (or both). Floating point literals or constants may be followed by T or 'F' to denote single precision constant, or 'd' or D to denote a double precision constants. The floating point literals could be written in two forms-Fractional form and Exponential form
E.g. 342.78F
Either a decimal point or an exponent must be present.
125 e 4.5 Exponent must be an integer.
3 Boolean Literals
Boolean literals have two values:
(a) true
(b) false
Single Character Literals
A single character literals is a single character, enclosed in apostrophes (single quotation marks). The character may be letter, number, or special character.
E.g. 'q'
Backslash Character Literals
Within character and string constants, the backslash character is special, and is used to represent characters not easily typed on the keyboard. These characters also known as escape sequenence.
Constant Meaning
n="newline character"
a = carriage return (without a line feed)
a tab
- a single quote (eg in a character constant)
- a double quote (eg. in a string constant)
- a single backlash
- a null character
String Literals
A string literals is a sequence of characters enclosed in double quotes. String Iterals automatically end with null character "0" Therefore, the string "Ram" will automatically be represented as "Ram0" in the memory and its size is not 3 but 4 characters.
E.g "D.S.C. "."4+8-6"
Null Literals
The Null theral can be used where a reference of object is expected. Nu conventionally represents an invalid or uncreated object.
Separators
Separators are the symbols used to indicate where the groups of code are divided
and arranged.
*Used to separate package names from subpackages and classes. Also used to separate a variable or method from a reference variable.
Knowledgeful material ππ
ReplyDeleteNice
ReplyDeleteVery good efforts π
ReplyDeleteNice content π
ReplyDeleteKnowledgeable content for bca students ππ
ReplyDeleteKeep it up ππ
ReplyDeletePlz share more data of this topic
ReplyDeleteVery good effortsπ
ReplyDelete