Posts

Showing posts with the label Variables in Java

Variables in Java. Types of variables (static, instance and local variable).

Variables  in   Java   : A variable  is a name of the memory location. It is used to store data. Its value can be changed, and it can be reused many times. variable is a storage area to hold data. Or variable is a name which is used to store a value of any type during program execution. Variable declaration : To declare the variable in Java, we can use following Syntax. Syntax : data_type variable_name; Example:  int  rno; String name; float percentage; char  grade; Here, rno, name, percentage, grade are variables. The int, float, char, String are the data types. Variable initialization : This means assigning a value to variables. Initializing  a variable means to provide it with a value. Syntax : variable_name = value; Example:  rno=10; name="arun"; percentage=89.99; grade='A'; A variable can be initialized and defined in a single statement, like: Syntax : data_type variable_name = value; Example : int  r...