posted 23 years ago
Originally posted by Angela D'souza:
So,If I have class bicycle:
In bicycle, if i declare Static Variable currentGear = 45.If I create 2 instance of this class, bicycle a, bicycle b and in a if can I change the the value of currentGear? If yes, then the value of currentGear in b and class itself will be changed or not???
same question for instance variable???
Notice the output after each change. Now remove the "static" modifier from currentGear, and see how the output differs. (Note: You will need to comment out this line:
System.out.println( "Bicycle.currentGear: " + Bicycle.currentGear );
or it won't compile.)
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt