集册 Java实例教程 将对象数组转换为字符串,适合在*Stat类的to string方法中使用。

将对象数组转换为字符串,适合在*Stat类的to string方法中使用。

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

400
将对象数组转换为字符串,适合在*Stat类的to string方法中使用。
/**来自 
 n o w    j a v a  . c o m**/

/*-

 * See the file LICENSE for redistribution information.

 *

 * Copyright (c) 2001,2007 Oracle.  All rights reserved.

 *

 * $Id: DbUtil.java,v 12.5 2007/05/17 15:15:42 bostic Exp $

 */

//package com.nowjava;


public class Main {

    /**

     *  Convert an object array to a string, suitable for use in

     *  toString methods of the *Stat classes.

     *

     * @return    Description of the Return Value

     */

    public static String objectArrayToString(Object[] arr, String name) {

        if (arr == null) {

            return "null";

        }


        StringBuffer sb = new StringBuffer();

        int len = arr.length;

        for (int i = 0; i < len; i++) {/* 来自 n  o  w  j  a  v  a . c o m*/

            sb.append("\n    " + name +
展开阅读全文