Overview
- Names used for classes, methods, interfaces
and variables are called Identifiers - All identifiers must start with either a letter
or currency character($) or a connecting
character like underscore(_). - A Java keyword cannot be used as an
identifier. - Identifiers in Java are case sensitive.
Identifiers
- Identifiers
- Variables & Constants
- Encoding Sets
- Separators
- Primitives
- Primitive Conversion
- Operators
Variables & Constants
- Declare variables
- Assign values to variables.
- Declare & Initialize
- Create constants
Encoding Set
- ASCII (American Standard Code for
Information Interchange)
• Represented in 8 bits and represents all
English alphabets, punctuations etc. - ISO-8859-1 (International Standards
Organization)
• 8 Bits and contains all characters
required for all western languages - Unicode
• Developed by Unicode Consortium
• Accommodates all characters of all
languages in world.
• Uses 16 bits.
- UTF-8
• Every character is encoded in 1 byte
• Suitable for texts having Latin letters. - UTF-16
• Commonly used characters are encoded
in 2 bytes
• Less common characters are encoded as
pairs of 16 bit code units. - UTF-32
• Uses 32 bits for every single character.
• Not a choice for Internet applications.
Separators
Symbol | Uses |
---|---|
. | Refer methods/fields of objects |
, | To separate arguments in method signatures. |
; | In For loops Terminate Statements |
{ } | Declare Arrays Blocks |
( ) | To evaluate Conditions Method signatures to contain lists of arguments. Narrowing conversions. |
[ ] | Declare Arrays Refer array values |
Pass parameters to parameterized types | |
: | In For loops |
Primitives
- byte
- short
- int
- long
- float
- double
- char
- boolean
Primitive Conversions
- Widening conversions
• byte to short,int,long, float
• int to long,float,double
• float to double - Narrowing Conversions
• short to byte
• int to short, byte
• double to float
Operators
- Unary Operators
- Arithmetic Operators
- Relational & Conditional Operators
- Assignment Operators
- Logical & Shift Operators
- Other Operators
These fundamental concepts are the building blocks of Java programming. Understanding them is essential for writing Java applications effectively and efficiently.