Collection

  • Published on
    This tutorial explores ways to divide a Java List, Set, or Iterable into batches. It covers creating custom batch list implementations, using Stream classes, Google Guava, and Apache Commons Collections. Each method includes examples and output. The tutorial emphasizes the importance of handling original collection changes and clarifies the difference between partitions and deep copies. Additionally, it provides the necessary dependencies for each library and demonstrates creating lists or iterables of batched data, ultimately facilitating traversal through the divided data. Also answers the question like, How to divide list in to batch?, How to divide Set or Iterable in to batch or partition?, How to convert List to List of List with java and it's library?
  • Published on
    This post presents methods for grouping User Defined Objects by one of their properties, commonly faced in coding. It offers examples using a POJO User class. Two approaches are described, traditional for loop grouping and using groupingBy Collectors of collection stream. Additionally, it covers arranging POGO by unique property using traditional Java and toMap Collectors of collection stream. These methods help minimize iterations when searching for the same type of property.