Here you can find the source of getMethodNames(Object obj, boolean includeInheritedMethods)
public static Set<String> getMethodNames(Object obj, boolean includeInheritedMethods)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 The University of York. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //from w w w . j a va 2 s.c o m * Contributors: * Dimitrios Kolovos - initial API and implementation ******************************************************************************/ import java.lang.reflect.Method; import java.util.HashSet; import java.util.Set; public class Main { public static Set<String> getMethodNames(Object obj, boolean includeInheritedMethods) { HashSet<String> methodNames = new HashSet<String>(); if (obj == null) return methodNames; Method[] methods = null; if (includeInheritedMethods) { methods = obj.getClass().getMethods(); } else { methods = obj.getClass().getDeclaredMethods(); } for (int i = 0; i < methods.length; i++) { methodNames.add(getMethodName(methods[i])); } return methodNames; } protected static String getMethodName(Method method) { String methodName = method.getName(); if (methodName.startsWith("_")) methodName = methodName.substring(1); return methodName; } }