title: How to call a void method in java using reflection
body: <p>If I call a method using reflection, the only way I can get it to work properly without throwing a null pointer exception is by returning an int value in the method I'm calling.</p>
  
  <p>For example, the method I want to call:</p>
  
  <pre><code>public int setScore(int n)
  {
  this.score = n;
  return 1;
  }
  </code></pre>
  
  <p>The way I call it:</p>
  
  <pre><code>Method setScore = myClass.getMethod("setScore", new Class&lt;?&gt;[]{int.class});
  Object returnValue = setScore.invoke(builder, new Object[]{theScore});
  </code></pre>
  
  <p>Changing the return type to void and calling it seems to always throw a null pointer exception. Do I need to change how I am approaching things for void methods?</p>
  
  <p>Thanks</p>