0% found this document useful (0 votes)
17 views2 pages

Variables in Java

Java variables are used to store data during program execution and are associated with a data type. There are three types of variables: local variables (declared within a method), instance variables (declared within a class but outside methods), and static variables (declared as static and cannot be local). Each type has specific scopes and usage rules in Java programming.

Uploaded by

pratikpund67
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Variables in Java

Java variables are used to store data during program execution and are associated with a data type. There are three types of variables: local variables (declared within a method), instance variables (declared within a class but outside methods), and static variables (declared as static and cannot be local). Each type has specific scopes and usage rules in Java programming.

Uploaded by

pratikpund67
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Variables In Java

Java Variables:
● Variables in java are used to Store the data while the java
program is executed.
● A variable is assigned with a data [Link] is a name
of memory location.
● A variable is the name of a reserved area allocated in
memory. In other words, it is the name of the memory
location.
There are three types of variables in java:

● Local variable.

● Instance variable.

● Static variable.

1) Local Variable:

A variable declared inside the body of the method is called a


local variable. You can use this variable only within that
method.
Note:A local variable cannot be defined with the "static"
keyword.

2) Instance Variable:

A variable declared inside the class but outside the body of the
method, is called an instance variable. It is not declared as
static.

3) Static variable:

A variable that is declared as static is called a static variable. It


cannot be local.

You might also like