Java Array Fill fill(byte[] arr)

Here you can find the source of fill(byte[] arr)

Description

fill

License

Open Source License

Declaration

public static List<Byte> fill(byte[] arr) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {

    public static byte[] fill(List<Byte> list) {
        if (list == null) {
            return new byte[0];
        }//w ww .  j  a  v  a 2 s . co  m
        int size = list.size();
        byte[] arr = new byte[size];

        for (int i = 0; i < size; i++) {
            arr[i] = list.get(i);
        }
        return arr;
    }

    public static List<Byte> fill(byte[] arr) {
        List<Byte> list = null;
        if (arr == null) {
            return new ArrayList<Byte>(0);
        }
        int size = arr.length;
        list = new ArrayList<Byte>(size);
        for (byte by : arr) {
            list.add(by);
        }
        return list;
    }
}

Related

  1. fill( T[] a, T val)
  2. fill(byte[] val, byte b)
  3. fill(char[] chars, int fromIndex, int toIndex, char c)
  4. fill(double[][] array, double s)
  5. fill(double[][] d, double val)