In Java can a method have anything close to a static variable in C?Although Java doesn’t provide one
That is,it would be initialized only once and keep latest value in subsequent recursive invocations
I could pass it back to the method to have the latest value and achieve ‘initalize only once’ based on some condition which holds true only once
int fun(.....,Nthcall,PseudoStatic)
{if(NthCall==1)
PseudoStatic=10
//rest of code
Pseudostatic=100
fun(.....,Nthcall+1,PseudoStatic)
}
Isn’t there something better?
We can do something like this
It’s not thread safe though. We can simply add
synchronized(class2value). Or use a weak concurrent hash map.