Here you can find the source of toList(byte[] array)
Parameter | Description |
---|---|
array | the array to convert |
public static List<Byte> toList(byte[] array)
//package com.java2s; /*/*from w ww .jav a 2s . c om*/ * This program 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. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; import java.util.List; public class Main { /** * Turns the byte array into a Byte list. * * @param array the array to convert * @return the generated list */ public static List<Byte> toList(byte[] array) { ArrayList<Byte> result; result = new ArrayList<>(); for (byte element : array) result.add(element); return result; } /** * Turns the int array into an Integer list. * * @param array the array to convert * @return the generated list */ public static List<Integer> toList(int[] array) { ArrayList<Integer> result; result = new ArrayList<>(); for (int element : array) result.add(element); return result; } /** * Turns the long array into a Long list. * * @param array the array to convert * @return the generated list */ public static List<Long> toList(long[] array) { ArrayList<Long> result; result = new ArrayList<>(); for (long element : array) result.add(element); return result; } /** * Turns the double array into a Double list. * * @param array the array to convert * @return the generated list */ public static List<Double> toList(double[] array) { ArrayList<Double> result; result = new ArrayList<>(); for (double element : array) result.add(element); return result; } /** * Turns the float array into a Float list. * * @param array the array to convert * @return the generated list */ public static List<Float> toList(float[] array) { ArrayList<Float> result; result = new ArrayList<>(); for (float element : array) result.add(element); return result; } }