title: java dynamically call methods
body: <p>I'm trying to figure out how to dynamically call a method. I have a string that describes the method name, but I'm not sure how to do it. I thought this could be done with reflection, but haven't had any success. Example</p>
  
  <pre><code>set.add(vehicleConfiguration.getVehicleYear.getName());
  
  set.add(vehicleConfiguration.getVehicleMake().getName());
  
  set.add(vehicleConfiguration.getVehicleModel().getName());
  </code></pre>
  
  <p>You'll notice all the method calls are the same with the exception of the getVehicleYear, etc</p>
  
  <p>I have a string that describes the method names, just not sure how to use it. </p>
  
  <p>I got as far as this with reflection, but failed.</p>
  
  <pre><code>set.add(Class.forName("VehicleConfiguration").getMethod("vehicleMake", null).getName());
  </code></pre>
  
  <p>Thanks in advance. </p>