集册 Java实例教程 将给定参数Types的类名呈现为逗号

将给定参数Types的类名呈现为逗号

欢马劈雪     最近更新时间:2020-01-02 10:19:05

461
将给定参数Types的类名呈现为逗号分隔的String。

/**

 * Copyright (c) 2011 eXtensible Catalog Organization

 *

 * This program is free software; you can redistribute it and/or modify it

 * under the terms of the MIT/X11 license. The text of the license can be

 * found at http://www.opensource.org/licenses/mit-license.php.

 *//*来 自 时   代    Java - nowjava.com*/

import org.apache.log4j.Logger;

import java.lang.reflect.Constructor;

import java.lang.reflect.Field;

import java.lang.reflect.InvocationTargetException;

import java.lang.reflect.Method;

import java.util.Collection;


public class Main{

    /**

     * Render the class names of the given parameterTypes as a comma-delimited String.

     * @param parameterTypes

     * @return

     */

    public static String parameterTypesToString(Class... parameterTypes) {


        String result;

        if (parameterTypes != null && parameterTypes.length > 0) {
        /*来自 
         n o w    j a v a  . c o m*/


            StringBuffer sb = new StringBuffer();

            for (Class c : parameterTypes) {


                sb.append(c.getName()).append(',');


            }


            
展开阅读全文