Java Variables

Types of Variables

  • Instance Variable: Non-static fields are also known as instance variables because their values are unique to each instance of a class.
  • Class Variables:class variable is any field declared with the static modifier; this tells the compiler that there is exactly one copy of this variable in existence; regardless of how many times the class has been instantiated.
  • Local Variables: Variables between the opening and closing braces of a method.
  • Parameters: The Arguments of a method or a constructor.

Naming Conventions

  • By convention it should start with the letter.
  • Avoid $ and _ characters in the names.
  • Whitespaces are not allowed.
  • Keyword or any reserved word should not be used.
  • For constants separate the words with the _.

No comments:

Post a Comment