Core Java
A Modern Communications Company
By Virendra Patel
A name in java program is
called identifier. It may be class
name, method name,
variable name and label name.
Identifiers
Rules to define java identifiers
Rule 1: The only allowed characters in java
identifiers are:
a to z
A to Z
0 to 9
_ (underscore)
$
Rules to define java identifiers
Rule 2: we Can not use any other character .
Example:
1. total_number
2. Total#
Rules to define java identifiers
Rule 3: identifiers are not allowed to starts with
digit.
Example:
feelfreetocode123
123feelfreetocode
Rules to define java identifiers
Rule 4: java identifiers are case sensitive up course java language itself
treated as case
sensitive language.
Example:
class HelloWorld {
int age=10;
int Age=20;
int AGE=20;
int AgE=30;
}
Rules to define java identifiers
Rule 5: There is no length limit for java identifiers
Rules to define java identifiers
Rule 5: There is no length limit for java identifiers
Rules to define java identifiers
Rule 6: We can't use reserved words as identifiers.
Example:
int else=10;
int if = 450;
Rules to define java identifiers
Rule 7: All predefined java class names and interface names we use
as identifiers.
Example 1:
class Test {
public static void main(String[] args){
int Integer=10;
[Link](Integer);
}
}
Let's Practice
MyVariable
myvariable
My Variable
9pins
MYVARIABLE
a+c
xi_myvariable
testing1-2-3
$myvariable
_9pins
andro
O'Reilly
This_is_an_insanely_long_variable_name_that_just_keeps_going_and_going_and_goi
ng_and_well_you_get_the_idea_The_line_breaks_arent_really_part_of_the_variable_n
ame_Its_just_that_this_variable_name_is_so_ridiculously_long_that_it_won't_fit_on_t
he_page_I_cant_imagine_why_you_would_need_such_a_long_variable_name_but_if_
you_do_you_can_have_it