Here you can find the source of prepend(String firstElement, String[] remaining)
public static String[] prepend(String firstElement, String[] remaining)
//package com.java2s; /*/* w w w.j a v a 2s .c o m*/ * Copyright (c) 2015-2017, Excelsior LLC. * * This file is part of Excelsior JET API. * * Excelsior JET API is free software: * you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Excelsior JET API is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Excelsior JET API. * If not, see <http://www.gnu.org/licenses/>. * */ import java.util.ArrayList; import java.util.Arrays; public class Main { public static String[] prepend(String firstElement, String[] remaining) { if (remaining == null) { return new String[] { firstElement }; } ArrayList<String> res = new ArrayList<>(); res.add(firstElement); res.addAll(Arrays.asList(remaining)); return res.toArray(new String[remaining.length + 1]); } }