Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.lang.reflect.Method;

public class Main {
    public static void toXml(Object bean) {
        Method[] declaredMethods = bean.getClass().getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            if (declaredMethod.getName().startsWith("get")) {
                try {
                    Object invoke = declaredMethod.invoke(bean);
                    System.out.println(declaredMethod.getName() + " = " + invoke);
                } catch (Exception e) {
                    e.printStackTrace(); //TODO To change body of catch statement use File | Settings | File Templates.
                }
            }
        }
    }
}