0% found this document useful (0 votes)
6 views3 pages

02 Variables Rules

The document outlines the rules for declaring variables in Java, emphasizing that variable names are case sensitive and can contain alphabets, numbers, underscores, or dollar signs. Variables must start with an alphabet, underscore, or dollar sign, cannot be keywords or class names, and have no length restrictions. Additionally, variable names should follow camel casing conventions.

Uploaded by

Avinash Nair
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)
6 views3 pages

02 Variables Rules

The document outlines the rules for declaring variables in Java, emphasizing that variable names are case sensitive and can contain alphabets, numbers, underscores, or dollar signs. Variables must start with an alphabet, underscore, or dollar sign, cannot be keywords or class names, and have no length restrictions. Additionally, variable names should follow camel casing conventions.

Uploaded by

Avinash Nair
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/ 3

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

You might also like