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 String getFields(Class clazz, Object object) {
        try {
            StringBuilder builder = new StringBuilder();
            Field[] fs = clazz.getDeclaredFields();
            for (Field f : fs) {
                f.setAccessible(true);
                builder.append(f.getName() + "=" + f.get(object) + "\r\n");
            }
            return builder.toString();
        } catch (Exception e) {
            return null;
        }
    }
}