☞The smallest individual unit in a program is known as token.
☞Tokens used in Java are : Keywords, Identifiers, Literals, Punctuators, and Operators
☞Identifiers are programmer-defined names given to the various program elements such as variables, functions, objects, classes, etc.
☞Examples of legal identifiers: age, _value, __1_value
☞Examples of illegal identifiers: 123abc, -salary, hello.file
➺It may contain digits, letters and underscore.
➺It must begin with a letter or underscore but not a digit.
➺Java is case sensitive.
☞The data items which never change their value throughout the program run.
☞There are several kinds of literals : Integer literals, Floating or Real literals, Character literals, String literals, Boolean literals, Null literal
➺They are whole numbers without any fractional part.
➺An integer literal must have at least one digit and must not contain any decimal point.
➺It may contain either + or - sign. A number with no sign is assumed as positive.
➺Example : 75, -98, +33, etc
➺Numbers which are having the fractional part are referred to as floating literals or real literals.
➺It may be a positive or negative number.
➺A number with no sign is assumed to be a positive number.
➺Example : 2.0, 17.5, -0.00256
➺Any single character enclosed within single quotes is a character literal.
➺Example : 'A', '3', ' ', '#'
Note : '3.4', '-4' etc are not a character literal because there is more than one character.➺It is a sequence of characters surrounded by double-quotes within a limit of 256 characters.
➺Example : "abc", "23", "1-h-4j-i"
➺It is true or false.
➺It denotes the absence of value.
➺It is used to initialize an object or array.
➺Example : Integer n = null;
☞Keywords are reserved words that convey a special meaning to the compiler.
☞Example :- if, else, default, switch, case, break, continue, do, while, for, true, false, new, null, package, private, public, byte, short, int, long, char, float, double, this, void, return, import, boolean, class etc.
Note : Keywords are always written in small letter.☞Punctuators are symbols that are used in programming languages to organize sentence structures, and indicate the rhythm and emphasis of expressions, statements, and program structure.
☞The following characters are used as punctuators:
[ ] | Brackets | These indicates single and multidimensional array subscripts |
() | Parenthesis | These indicate function calls and function parameters. |
{ } | Braces | Indicate the start and end of compound statements. |
; | Semicolon | This is a statement terminator. |
, | Comma | It is used as a separator. |
: | Colon | It indicates a labeled statement |
= | Equal to | It is used as an assigning operator. |
☞An operator is a symbol or character which triggers some operation (computation) on its operands.
☞Types of operators:- Unary Operators, Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators, Conditional Operator, Assignment Operators,