title: Reflecting changes to a variable in the caller in Java
body: <p>I have a function that is supposed to return a place object, but I also need to test on whether something evaluates to false, and in addition the caller needs to know both of those pieces of information. I have the return type as Place but in Java there are no reference parameters, so if the following if-condition is true, I would like for some way to reflect that in the caller so I can check it, but I can't have more than one return type so I'm stuck as to what to do. My best shot was returning null but I just get the feeling that this is bad programming.</p>
  
  <p>if ( directions.get(i).isLocked() )</p>
  
  <p>Below is the complete function:</p>
  
  <pre><code>Place followDirection(String dir, boolean isLocked) { 
          dir = dir.toLowerCase(); // make sure the string is lowercase for comparisons
  
          int i = 0;
  
          for ( i = 0; i &lt; directions.size(); i++ ) { // loop until we find a match, remember that if it's locked then we cnanot go in there
              if ( directions.get(i).getDirection().equals(dir) ) {
                  if ( directions.get(i).isLocked() ) {
                      System.out.println("This room is locked, sorry");
                  }
                  else {
                      return directions.get(i).getToPlace(); // this means we found a match, return the destination
  
                  }
              }
          }
  
          Place p = null;
          return p;
      }
  </code></pre>