Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.lang.reflect.Field;

public class Main {
    public static void setField(Class cls, String name, Object obj, Object value) {
        try {
            Field nameField = cls.getDeclaredField(name);
            nameField.setAccessible(true);
            nameField.set(obj, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}