Here you can find the source of toStringArray(Collection> collection)
Parameter | Description |
---|---|
collection | the collection |
public static String[] toStringArray(Collection<?> collection)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Collection; public class Main { /**/*ww w . j a v a2s . co m*/ * Returns an array containing string representations of the elements in the collection. * * @param collection the collection * @return the array */ public static String[] toStringArray(Collection<?> collection) { String[] result = new String[collection.size()]; int index = 0; for (Object entry : collection) { result[index] = String.valueOf(entry); index += 1; } return result; } }