get Static Methods from a Class - Android java.lang.reflect

Android examples for java.lang.reflect:Method Get

Description

get Static Methods from a Class

Demo Code


//package com.java2s;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static List<Method> getStaticMethods(Class<?> clazz) {
        List<Method> methods = new ArrayList<Method>();
        for (Method method : clazz.getMethods()) {
            if (Modifier.isStatic(method.getModifiers())) {
                methods.add(method);/*from w  w w.  ja  v  a 2  s  .  co  m*/
            }
        }
        return Collections.unmodifiableList(methods);
    }
}

Related Tutorials