Ad Code

Responsive Advertisement

Varibles in java || sweetymyworld ||

 Variables in Java



Variables :

A variable is an identifier that denotes a storage locating used to store a data value. A variable name can be choosenu by the programmer in a meaning ful way
 A variable may take different values at different times during the execution of program.


Declaration of variables :

In java after designing suitable names for variables we must declare them to the compiler.

In the declaration section we define variable name and type of the data variable. A variable must be declare before it is used .


Syntex for Variable Declaration :

Type var 1,var 2,.....var n ;

Ex : 
Int count ;
Float salary ;
Char name ;



Assigning a value to a variable :

 We can assign a values to a variable in two ways
  1. By using Assigning statement
  2. By using a Read statement


Assinging Statement : 

It is a simple method of given values to a variable through the assignment statement

Variable name = value 

Ex :
int x = 0;
Float pi= 3.14;

Read Statement :

We may also give values to variables interactively through the keyboard using the " Read line () method "




Some more posts :

Arrays in java (click here)

Variables in java(click here)




Post a Comment

0 Comments

Close Menu