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 {
    private static void setField(Object obj, Class<?> cls, String field, Object value) {
        try {
            Field localField = cls.getDeclaredField(field);
            localField.setAccessible(true);
            localField.set(obj, value);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}