Java
Rules for variables
1. Case Sensitive
Ex :
int amount;
int Amount;
• These both are di erent variables
2. Contains Alphabets , Numbers _ or $
Ex :
int room1;
int cabin51;
int room_number
oat total$amount
fl
ff
3. Starts with Alphabet _ or $
Ex :
byte x1;
byte _x;
4. Should not be keyword
Ex : These are the keywords which we cannot use while declaring a
variable
5. Should not be class name , if class is also in use
Ex :
• If string class is used then the variable cannot have the
same name as the class
string
int string
6. No limit on length on names
• You can declare a variable name as small as possible or
as large as possible
7. Follows camel casing
The rst letter of a word must be capital except for the rst
word
Ex :
byte rollNumber;
fi
fi