title: Dynamic Return Type in Java method
body: <p>I've seen a question similar to this multiple times here, but there is one big difference.</p>
  
  <p>In the other questions, the return type is to be determined by the parameter. What I want/need to do is determine the return type by the parsed value of a <code>byte[]</code>. From what I've gathered, the following could work:</p>
  
  <pre><code>public Comparable getParam(String param, byte[] data) {
      if(param.equals("some boolean variable")
          return data[0] != 0;
      else(param.equals("some float variable") {
          //create a new float, f, from some 4 bytes in data
          return f;
      }
      return null;
  }
  </code></pre>
  
  <p>I just want to make sure that this has a chance of working before I screw anything up. Thanks in advance.</p>