What is the best way to create a C-style static variable in Java (local to a method)?
I have a method in which I need to calculate a variable only once, and do not need to recalculate it for the lifetime of the object.
I understand that I could create a final field, but this variable may not be required in all cases and would only be required if this method in question is called at all by the client.
Any pointers on how I could achieve this?