Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Lorraine Stephens   on Sep 18 In Java Category.

  
Question Answered By: Adelfrid Fischer   on Sep 18

This is a brief explanation of Variables in Java.
Java has three kinds of variables:
1. local (automatic)
2. Instance
3. Class
Local variables are declared within a method body. Both instance  and
class variables are declared inside a class  body but outside of any method
bodies. Instance and class variables look similar, except class variables are
prepended with the static modifier.
Again an instance variable  occurs once per instance of a class; that is, every
time you create a new instance of the class, the system allocates memory for all
of the class's instance variables. This is in constrast to class variables which
occur once per class regardless of the number of instances created of that
class. The system allocates memory for class variables the first time it
encounters the class.

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on what is instance variable and class variable. Or get search suggestion and latest updates.


Tagged: