title: How can I avoid to do a lot of if's in java ?
body: <p>In c++, I would use a map of int/pointer to function like this : </p>
  
  <pre><code>std::map = {
  {Code::Value1, Handler::value1Handler},
  {Code::Value2, Handler::value2Handler},
  };
  </code></pre>
  
  <p>To avoid to do a lot of if's like </p>
  
  <pre><code>if (value == Code::Value1)
    value1Handler();
  if (value == Code::Value2)
    value2Handler();
  if (value == Code::Value3)
    value3Handler();
  </code></pre>
  
  <p>But I didn't find a good way to do this in Java, is it possible ? </p>