
class A
{
int a; //instance variable
static int b; // static variable
A ref;
static A refs;
public static void main(String[] args)
{
// statements followed here...
}
}
My Question is that instance variable occupy space in memory when object is created. Static variable is class variable which is shared. I just want to ask if we declare Reference variable above then what does that mean. like we declared 'A ref' and 'static A refs'. How this is treated??
(Generally we used to declare reference variable in main method at the time of object creation, but here i am declaring reference variable in class not in the main, so what is the difference and second what is the use of static reference variable)
please explain with example??
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.