aspose file tools*
The moose likes Java in General and the fly likes Reassigning class variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reassigning class variable" Watch "Reassigning class variable" New topic
Author

Reassigning class variable

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Here i is a class variable, are we allowed to change value assigned to class varaible ?

D. Ogranos
Ranch Hand

Joined: Feb 02, 2009
Posts: 214
You can reassign any variable that is not marked "final". Note however that what you have in your example is NOT a class variable (marked with "static"). Class variables only exist once, regardless how many object instances you create. So if one object changes the value, all other instances will see the change. Instance variables (such as your variable "i") on the other hand exist for each object instance, so a change in one instance won't be noted in any other instance.
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Thanks a lot for your response
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reassigning class variable