Question: I getting class by name and i need to update them with respective data and my question is how to do it with java 
I want to add the method some dummy data .
I don't know the class type I just getting the class name and use reflection to get his data 

I use this code to get the class instance and 

```
Class<?> classHandle = Class.forName(className);

Object myObject = classHandle.newInstance();

// iterate through all the methods declared by the class
for (Method method : classHandle.getMethods()) {
    // find all the set methods
    if (method.getName().matches("set[A-Z].*")

```

And know that I find the list of the set method I want to update it with data 
how can I do that .

assume that In class name I got person and the class have setSalary and setFirstName etc 
how can I set them with reflection ?

```
public class Person {

    public void setSalery(double salery) {
        this.salery = salery;
    }

    public void setFirstName(String FirstName) {
        this.FirstName = FirstName;
    }   
}

```

Answer: 
To update the first name

* First find the field you want to update
* Then find the mutator (which accepts an argument of the field's type)
* Finally execute the mutator on the object with the new value:

```java
Field field=classHandle.getDeclaredField("firstName");
Method setter=classHandle.getMethod("setFirstName", field.getType());
setter.invoke(myObject, "new value for first name");

```
```
if (method.getName().matches("set[A-Z].*") {
  method.invoke(person,salary)
  // and so on
}

```

to know the parameters you can issue `method.getPagetParameterTypes()`
based on the result construct your parameters and supply.