I have an array of which I want to create List with each list have only one element of array. So for array {1,2,3} I want to create 3 List with each having element 1, 2 and 3 respectively.
Have done it using java 7 but wanted to know if it can be solved using java 8 stream, maps etc
Thanks
Integer[], you can useList<List<Integer>> list = Arrays.stream(array).map(Collections::singletonList).collect(Collectors.toList());, for anint[], you only have to changemaptomapToObj…