0% found this document useful (0 votes)
35 views11 pages

1 Core Java Identifiers

This document outlines 7 rules for defining Java identifiers: 1. Identifiers can only contain letters, digits, underscores, and dollar signs. 2. Other characters besides those listed in rule 1 are not allowed. 3. Identifiers cannot start with a digit. 4. Java is case-sensitive, so identifiers like age and Age are different. 5. There is no length limit for identifiers. 6. Reserved words like else and if cannot be used as identifiers. 7. Predefined class and interface names can be used as identifiers.

Uploaded by

debjit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views11 pages

1 Core Java Identifiers

This document outlines 7 rules for defining Java identifiers: 1. Identifiers can only contain letters, digits, underscores, and dollar signs. 2. Other characters besides those listed in rule 1 are not allowed. 3. Identifiers cannot start with a digit. 4. Java is case-sensitive, so identifiers like age and Age are different. 5. There is no length limit for identifiers. 6. Reserved words like else and if cannot be used as identifiers. 7. Predefined class and interface names can be used as identifiers.

Uploaded by

debjit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

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;
System.out.println(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

You might also like