java集合转换为行_Java 将集合转换为字符串数组

//package com.nowjava;

/**

* n o w j a v a . c o m 提 供

**/

import java.util.Collection;

public class Main {

public static void main(String[] argv) {

Collection collection = java.util.Arrays.asList("asdf",

"nowjava.com");

System.out.println(java.util.Arrays

.toString(toStringArray(collection)));

}

/**

* Converts collection to array of strings

* @param collection source collection

*/// 来自 n o w j a v a . c o m - 时代Java

public static String[] toStringArray(Collection collection) {

if (collection == null) {

return null;

}

if (collection.isEmpty()) {

return new String[] {};

}

int index = 0;

String[] result = new String[collection.size()];

for (Object item : collection) {

/**代码未完, 请加载全部代码(NowJava.com).**/

//package com.nowjava; /** * n o w j a v a . c o m 提 供 **/ import java.util.Collection; public class Main { public static void main(String[] argv) { Collection collection = java.util.Arrays.asList("asdf", "nowjava.com"); System.out.println(java.util.Arrays .toString(toStringArray(collection))); } /** * Converts collection to array of strings * @param collection source collection */// 来自 n o w j a v a . c o m - 时代Java public static String[] toStringArray(Collection collection) { if (collection == null) { return null; } if (collection.isEmpty()) { return new String[] {}; } int index = 0; String[] result = new String[collection.size()]; for (Object item : collection) { /**代码未完, 请加载全部代码(NowJava.com).**/
经验分享 程序员 微信小程序 职场和发展