Either you noted the correct answer, which was not, or you really need variables of the static class, but the correct answer is basically Levitic, or technically a mixture of all the answers.
For people from a C-background like me, really wanting static function-local variables, solely for the advantages of the region over global ones, it seems like you can't in Java. Not without execution, something like @paradigmatic happens to a class instance with a static global and getter (), unique to the class instance in which you use your function.
If, as I suspect, you are using the class as Singleton or completely static, as a programmer with very complex procedures, we all started, as @Ellie P or @ user2626445 answer will work fine, since no other instance will blame your global one. But in order to achieve what you think you want, it should be just an instance variable that is global in C. They are stored in all function calls, but allow you to use your function in the OO method, so several instances can save their own own constant variables for this particular function.
Personally, I will get around this in jave just like Hi-Tech C, by not allowing function bits to be variable by declaring a global value in the file just above the function declaration. So, when I crack the code later, Iβm less likely to think that itβs global, and the temptation to work with it is β donβt we encapsulate things?
Alex K Jan 18 '16 at 12:21 2016-01-18 12:21
source share