Support Me ��


SUBSCRIBE NOW

Basic JAVA 1


Basic JAVA 1

Variable in Java 

Variable is name of reserved area allocated in memory.

int data=50; // Here data is variable.

Types of Variable in Java:

  1. Local Variable
  2. Instance Variables (Non-static variables)
  3. Class Variables (Static Variables)

1) Local Variables:

Local variables are declared in method constructor or blocks. Local variables are initialized when method or constructor block start and will be destroyed once its end. Local variable reside in stack. Access modifiers are not used for local variable.

Ex: 

float getDiscount(int price)
{
float discount; //here discount is a local variable
discount=price*(20/100);
return discount;
}

2) Instance Variables:

A variable that is declared inside the class but outside the method, constructor or block is called instance variable . It is not declared as static.

Ex:

class Student
{
String name; //here name and age are
int age; // instance variable
}

3) Static variables:

A variable that is declared as static is called static variable. It cannot be local. Static variables are initialized only once. Static variables are also used in declaring constant along with final keyword.

Ex: 

class Student
{
String name;
int age;
static int instituteCode=1101;
} //here instituteCode is a static variable

Dinesh Kumar S is a 23-year-old System Administrator who enjoys playing games, listening to music and learning new technology. He is friendly and generous, but can also be very lazy and crazy.

Share this

Backlinks

Website Design Company in Coimbatore
Website Design Company in Tamil nadu
Website Design Company in Karur
Website Design Company in Erode
Website Design Company in ooty
Website Design Company in theni
Website Design Company in thoothukudi
Website Design Company in Chennai
Website Design Company in Sathy
Website Design Company in Coimbatore Tamilnadu
Cheap Website Design Company in Coimbatore
Adsense Website Design Company in Coimbatore
ecommerce Website Design Company in Coimbatore
school Website Design Company in Coimbatore
Academy Website Design Company in Coimbatore
Test Website Design Company in Coimbatore
Best Website Design Company in Coimbatore
Adsense Website Design Company in Coimbatore
Adsense Website Design Company in Tamil nadu
Adsense Website Design Company in Karur
Adsense Website Design Company in Erode
Adsense Website Design Company in ooty
Adsense Website Design Company in theni
Adsense Website Design Company in thoothukudi
Adsense Website Design Company in Chennai
Adsense Website Design Company in Sathy
Free SEO Tools online
Free SEO Tools online Website
Free SEO Tools online Plagiarism
Free SEO Tools online article rewriter tool
Free SEO Tools online article reading and writing criticism
Free SEO Tools online seo backlink
Free SEO Tools online Free backlink maker
Free SEO Tools online seo backlink strategy
Free SEO Tools online content writting
360 help SEO Tools online Plagiarism checker
360 help SEO Tools online seo backlink
360 help SEO Tools online Free backlink maker
360 help SEO Tools online content writting
360 help SEO Tools online article rewriter tool
360 help SEO Tools
360 help SEO Tools India
360 help SEO Tools Tamil
360 help SEO Tools website