Reputation: 337
Bit of basic question but even after reading loads over net I am clueless about the usage of static for variables in a web-applicaton.
Problem: In my web-application deployed over weblogic, i am declaring a static variable and assigning its value as 0.
public static int startIndex = 0;
Now, I am using this variable in my method and making few changes to its value depending on the requirement. My query is, if I make a change in its value say, startIndex=100
, then when will it be assigned back to 0? That is, at what point of time will this static variable startIndex
will be set back to its initial value?
Is at server rebounce or each time when that class will be referenced in the same session or difference session? Clueless!! Any suggestions would be helpful. Thanks :)
Upvotes: 1
Views: 234
Reputation: 68715
static
variable value is set at the class loading.
So whenever the class is loaded/re-laoded i.e. application (re)deployed, server restart, class reloading by Classloader, etc
Apart from that manual setting to default by code.
Upvotes: 4