Java Array to List toList(int[] a)

Here you can find the source of toList(int[] a)

Description

to List

License

Open Source License

Declaration

public final static List<Integer> toList(int[] a) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public final static List<Integer> toList(int[] a) {
        if (a == null)
            return null;

        List<Integer> li = new ArrayList<Integer>(a.length);
        for (int i = 0; i < a.length; i++) {
            li.add(a[i]);//from ww w .j  a va 2 s.  c  o  m
        }

        return li;
    }

    public final static List<String> toList(String[] a) {
        if (a == null)
            return null;

        List<String> li = new ArrayList<String>(a.length);
        for (int i = 0; i < a.length; i++) {
            li.add(a[i]);
        }

        return li;
    }
}

Related

  1. toList(final T[] array)
  2. toList(final T[] array)
  3. toList(final T[] array)
  4. toList(final T[] array)
  5. toList(final T[] array)
  6. toList(int[] arr)
  7. toList(int[] array)
  8. toList(int[] array)
  9. toList(int[] from)