Best practice for defining a Java variable that acts (something) like a C's local static variable
<p>In C, I can create a static variable in a function. The space for that variable is not allocated along with the function variables, it's allocated at program startup time. (Don't mock my C too harshly, I've been programming in Java for way too long :)</p>

<pre><code>void myFunc(){
  static SomeStruct someStruct;
  someStruct.state=INITIALIZED;
  goDoSomethingInteresting(MY_COMMAND,&amp;someStruct);
}
</code></pre>

<p>In Java, if I want to do something similar, I create a class variable and then use it.</p>

<pre><code>Class TheClass {
   SomeStruct someStruct = new SomeStruct();
   void myFunc(){
     someStruct.setState(INITIALIZED);
     goDoSomethingInteresting(MY_COMMAND,someStruct);
   }
}
</code></pre>

<p>My question is what is the best practice for doing something like this? I'd really like to associate my variable <code>someStruct</code> with my function <code>myFunc</code>, because <code>myFunc</code> is the only code that should know about or use <code>someStruct</code>, but there's no way to make that association except to put the variable close to the function in code. If you put it above, then the Javadoc for the function looks wonky, if you put it below, then it's not very clear that they belong together.</p>

<p>Normally I would just create <code>someStruct</code> locally, but in my case it's very expensive to create <code>someStruct</code>, and I call <code>myFunc</code> in a tight loop.</p>
