title: Java reflection - how to call getter/setter method?
body: <p>I'm trying to call set method of some property that I got in my object, my code goes like this:</p>
  
  <pre><code>    String[] fieldsStringName = (((CacheObject)currentObject).getFieldsToString(false)).split(", ");
      String methodName = "";
  
      for (int i = 0; i &lt; objectInputArr.length; i++) {
          methodName = "set" + fieldsStringName[i];
  
          Method methodSetProperty = currentObject.getClass().getMethod(methodName);   &lt;&lt;----error occurs here
          methodSetProperty.invoke(currentObject, objectInputArr[i]);
      }
  </code></pre>
  
  <p>The error that i'm getting is:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoSuchMethodException: model.Book.setPagesAmount()
      at java.lang.Class.getMethod(Unknown Source)
      at CahceSystem.createNewObject(CahceSystem.java:84)
      at CahceSystem.main(CahceSystem.java:50)
  </code></pre>
  
  <p>The requested setter method is well written in the class and also in it's super class (inherited propeties only), all my setter's methods are like:</p>
  
  <pre><code>public void setPagesAmount(int pagesAmount) {
      this.pagesAmount = pagesAmount;
  }
  </code></pre>
  
  <p>Any suggestions how to solve this issue?</p>