DEV Community

SELVAKUMAR R
SELVAKUMAR R

Posted on

IDENTIFIER, LITERALS, KEYWORD

1. Identifier:

-> Name given to various program element for identification
-> Identification name start with character (a to z or A to Z) and also start with underscore( _ ) or dollar symbol ($)

Ex:
_myvariable , $price

-> Identifer declaration cannot start with digit

Ex:
123variable , 9_price -> invalid declaration

-> Identifier are case sensitive

2. Literals:

Literals are constant values that are assigned to variable or used in expression

It cannot be changed during program execution

Types:

Integer

-> Represent whole number
-> Octal (base 8 prefixed with 0) -> Eg: 0146
-> Hexadecimal (base 16 prefixed with 0x or 0X) -> Eg: 0x65

Floating point

-> By Default the float number are in double type
-> To specify a float literal you can append f or F
Eg: float temperature : 23.5 F;

Character Literal

Represent the single character enclosed with single quotes ( ' ' )

\n -> new line
\t -> new tab
\u0041 -> unicode for 'A'
Enter fullscreen mode Exit fullscreen mode

String Literal

Represent a sequence of character enclosed with double quotes ( " " )

Java treats string literal as string object

Eg:

string greeting = "Hello, Vijay" ;

Boolean Literals

It represent Logical Value -> True or False

3. Keyword

It is a reserved word cannot be used as variable , method, class name

Eg:

Data Type : int, double, boolean, float, char, byte, long, short

Control flow :if , else, for, while, do, switch, break, continue, return

class and object : class, new, extends, implements, interface, abstract, final, static, this, super

Access Modifier : public , private, protected

Exception Handling : try , catch, final, throw, throws

camel Case:

First letter of the first word is lower case

Used for variable name, method name

Eg:

int calculateTotalAmount()

Pascal Case :

First letter of every word is capitalized

Used for Class Name, Interface Name

Eg:

class MyClass

interface DataProcessor
Enter fullscreen mode Exit fullscreen mode

Top comments (0)