import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

public class Part {

public static Collection <List <Object>> main(List<String> list) {

Collection Rlist = Arrays.asList();

Rlist = partition(list, 6);

return Rlist;
}

private static <T> Collection<List<T>> partition(List<T> list, int size) {
final AtomicInteger counter = new AtomicInteger (0);
return list.stream ()
.collect (Collectors.groupingBy (it -> counter.getAndIncrement () / size))
.values ();

}


}

===================================================결과==============================================

[09, 10, 12, 17, 23, 09]
[17, 19, 26, 61, 62, 15]
[16, 18, 27, 55, 67, 18]
[02, 17, 20, 38, 39, 20]
[08, 24, 42, 54, 64, 24]

Process finished with exit code 0



posted by jofw


티스토리 툴바