Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Field;

import java.util.*;

public class Main {
    public static Field findField(Object target, List<String> possible_names) {
        if (target == null)
            return null;
        for (Class<?> clazz = target.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
            for (String name : possible_names) {
                try {
                    return clazz.getDeclaredField(name);
                } catch (Exception e) {
                }
            }
        }
        return null;
    }
}