English, asked by ss4421898, 11 months ago

List partition ing method use<br />​

Answers

Answered by kshitizbitu7256
0

Answer:

public static <T> List<List<T>> partition(List<T> list, int size)

Parameters: The method accepts two parameters:

list: The list which is to be divided into sublists based on the partition size.

size: The desired size of each sublist. The size of the last sublist may be smaller.

Return Value: The method returns the list of consecutive sublists. Each sublist(except possibly the last one) has the size equal to the partition size.

Exception: The method Lists.partition() throws IllegalArgumentException if partition size is non-positive.

Explanation:

The Lists.partition() method is used to divide the original list into sublists of the same size. The method accepts two parameters.

For example: If the original list passed as parameter is [a, b, c, d, e] and the partition size is 3, then the sublists yield are as [[a, b, c], [d, e]].

Similar questions