Computer Applications

What are the rules to assign a variable in Java programming?

Values & Data Types Java

89 Likes

Answer

The rules to be followed while naming a variable in Java programming are as follows:

  1. A variable may have any number of characters.
  2. It may contain letters, digits and a underscore.
  3. It must not start with a digit or special character.
  4. It must not contain spaces, punctuation marks or any symbol.
  5. The underscore can be inserted in between the characters to separate the words, in case a variable includes multiple words.
  6. Variable name should be meaningful which specifies what it represents.

Answered By

47 Likes


Related Questions