DEV Community

Hamid Mohamadi
Hamid Mohamadi

Posted on

Lesson 6 : Literals , Keywords and Identifiers

Literal is the value assigned to a variable :

Alt text of image
Literals categories :

- Integer literals

- String literals

- Boolean literals

- Character literals

- Float literals

- Null literals

Keywords :

Keywords are the predefined words having any specific meanings :

Alt text of image

Identifiers :

Identifier is any name , it can be a variable name , class name or method name :

Alt text of image

Rules for Identifiers :

1- space can not be used :

int emp no = 10 ; ---------> int emp_no = 10 ;

2- only underscore( _ ) and dollar ( $ ) can be used :

int emp_no = 10 ;

3- Reserved word can not be used :

int public = 10 ; ----------> int a = 10 ;

4- Integer values can not be used at first position but it can be used after first character :

int 1abc = 10 ; -----> int a1bc = 10 ; int abc1 = 10 ;

Naming Conventions :

variable -----------> my , my_java , my_java_demo

methods----------> my() , myJava() , my java demo()

class/interface----> My , MyJava , MyJavaDemo

Top comments (0)