title: return "constant" value from method java
body: <p>I'm not quite sure if this is possible so that's why I ask you guys. I want to write a method that knows if it has been visited before and if it has return the same value it has lasttime it were visited. I can't use fields/instance varibles for this.</p>
  
  <p>This is want I want to do, without the instance variable foo:</p>
  
  <pre><code>private FooObject foo = null;
  public int setFoo(FooObject in)
  {
      if(foo == null)
          foo = in;
  
      return foo.getX();
  }
  </code></pre>
  
  <p>Could this be done?</p>