SHARE
TWEET

int[] to List<Integer>

DulcetAirman Dec 18th, 2016 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ch.claude_martin.playground;
  2.  
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import java.util.stream.Collectors;
  6.  
  7. public class SomeClass {
  8.  
  9.     public static void main(String[] args) {
  10.         int[] a = { 1, 2, 3, 4 };
  11.         List<Integer> list = toList(a);
  12.         System.out.println(list);
  13.     }
  14.  
  15.     public static List<Integer> toList(int[] a) {
  16.         return Arrays.stream(a).mapToObj(Integer::valueOf).collect(Collectors.toList());
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top