package lambdas;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class UsePerson {
@SuppressWarnings({"UnusedAssignment", "Convert2MethodRef"})
public static void main(String[] args) {
List names = Arrays.asList("John", "Paul", "George", "Ringo");
List people = names.stream() // Stream
.map(name -> new Person(name)) // Stream
.collect(Collectors.toList()); // Converts Stream to List
people = names.stream()
.map(Person::new)
.collect(Collectors.toList());
System.out.println(people);
Person[] peopleArray = names.stream()
.map(Person::new)
.toArray(Person[]::new);
System.out.println(Arrays.toString(peopleArray));
}
}