As of Guava 21, this is possible via Streams.zip()
:
List<Person> persons = Streams.zip(names.stream(), ages.stream(), Person::new)
.collect(Collectors.toList());
More Related Contents:
- Why does compiler gives this exception [closed]
- Map implementation with duplicate keys
- Combine multiple Collections into a single logical Collection?
- What’s the point of Guava’s Optional class
- builder for HashMap
- Why does Guava’s ImmutableList have so many overloaded of() methods?
- Predicate in Java
- How can I generate a list or array of sequential integers in Java?
- Sort List in reverse in order
- java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;I)V with IE and Selenium through Java
- Google Guava vs. Apache Commons [closed]
- Bi-directional Map in Java? [duplicate]
- Map that could be iterated in the order of values
- org.openqa.selenium.remote.service.DriverService$Builder.createArgs()Lcom/google/common/collect/ImmutableList; with Selenium 3.5.3 Chrome 76
- java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap error using GeckoDriver Firefox through Selenium in Java
- Simplest way to iterate through a Multiset in the order of element frequency?
- Google Guava isNullOrEmpty for collections
- Managing highly repetitive code and documentation in Java
- How to transform List to another List [duplicate]
- Java: null pointer exception when unboxing Integer?
- Filtering a list of JavaBeans with Google Guava
- Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)
- How to create a Multimap from a Map?
- Get minvalue of a Map(Key,Double)
- Idiomatic way to use for-each loop given an iterator?
- Java-get most common element in a list
- How to do map inversion with Guava with non-unique values?
- What is the use of a private static variable in Java?
- Mockito’s Matcher vs Hamcrest Matcher?
- Android: How to pause and resume a Count Down Timer?