Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.Collection;

public class Main {
    public static Collection<?> getFieldFrom(Collection<?> set, String FieldName) {
        ArrayList arrayList = new ArrayList();
        for (Object o : set) {
            try {
                Object object = o.getClass().getField(FieldName).get(o);
                arrayList.add(o);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}