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 {
    /**
     * Gets the given field's value of the specified object instance, or null if
     * the value cannot be obtained.
     */
    public static Object getValue(final Field field, final Object instance) {
        try {
            field.setAccessible(true);
            return field.get(instance);
        } catch (final IllegalAccessException e) {
            return null;
        }
    }
}