Variables-Java



This content originally appeared on DEV Community and was authored by Sri Raam

Image description

  1. Objects
  2. Types of Variables
  3. Comments
  4. Keywords

OBJECTS

  • Variables are the state of the objects, i.e the entities that store the numeric units of the Real-time objects.
  • Methods are the behaviour of the object, i.e the functions done by the object.

TYPES OF VARIABLES

  • The variables in Java can be classified into two types based on their scope, namely: 1. Global Variables, 2.Local Variables
  1. Global Variables -Global Variables can be used throughout the program.
  2. Mapping a literal to a variable is known as assigning or initialising. e.g, int pixel=10;
  3. Introducing a variable without assigning a value is known as declaring. e.g, [int a;](url)

  4. Local Variable

  5. A Local Variable can be declared and accessed only within a method.

COMMENTS

Comments are blocks of code that are hidden from the end user and are used for the programmer’s understanding.

  • Single Line Comment: // is used for comments that end within a line.
  • Multi-Line Comment: /** and /** are used for comments that take up multiple lines, and the comments are entered within /** and **/.

KEYWORDS

  • Keywords are words that perform certain significant functions in the code.
  • Keywords are also known as Reserved words.
  • e.g, new, int, float, byte, short, long, double, boolean, char, short, class, package.


This content originally appeared on DEV Community and was authored by Sri Raam