DulcetAirman icon

int[] to List<Integer>

DulcetAirman | PRO | 12/18/16 09:14:17 PM UTC | 0 ⭐ | 840 👁️ | Never ⏰ | []
Java |

430 B

|

None

|

0 👍

/

0 👎

package ch.claude_martin.playground;
 
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
 
public class SomeClass {
 
    public static void main(String[] args) {
        int[] a = { 1, 2, 3, 4 };
        List<Integer> list = toList(a);
        System.out.println(list);
    }
 
    public static List<Integer> toList(int[] a) {
        return Arrays.stream(a).mapToObj(Integer::valueOf).collect(Collectors.toList());
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎