Here you can find the source of toArrays(Collection
public static char[][] toArrays(Collection<String> strings)
//package com.java2s; /******************************************************************************* * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w ww . j a va 2 s . co m * IBM Corporation - initial API and implementation * daolaf@gmail.com - Contribution for bug 3292227 *******************************************************************************/ import java.util.Collection; public class Main { public static char[][] toArrays(Collection<String> strings) { char[][] arr = new char[strings.size()][]; int i = 0; for (String str : strings) { arr[i++] = str.toCharArray(); } return arr; } }