提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
修剪字符串数组中的字符串内容。
//package com.nowjava; /** 来 自 N o w J a v a . c o m**/ public class Main { public static void main(String[] argv) { String array = "nowjava.com"; System.out.println(java.util.Arrays.toString(trimArray(array))); } /** * Trims the String content on an array of String. * * @param array String array to trim contents. */ public static String[] trimArray(final String... array) { String[] retval = null; //NOPMD: null default, conditionally redefine. if (array != null) { retval = new String[array.length]; /** from nowjava - 时代Java**/ System.arraycopy(array, 0, retval, 0, array.length); for (int i = 0; i < retval.length; i++) { if (array[i] == null) {