Question: public void countPets ( ) { record Pet ( int age ) { } record PetSummary ( long count, int sum ) { } var

public void countPets(){
record Pet(int age){}
record PetSummary(long count, int sum){}
var summary = Stream.of(new Pet(2), new Pet(5), new Pet(8))
.collect(Collectors.teeing(
Collectors.counting(),
Collectors.summingInt(Pet::age)));
System.out.println(summary);
}
A The code does not compile since records are defined inside a method.
B The code does not compile due to the teeing() call.
C PetSummary [count=3, sum=15]
D PetSummary[count=3, sum=3]
E PetSummary[count=1, sum=15]
F PetSummary[count=1, sum=3]
G
The code does not compile for another reason.
public void countPets ( ) { record Pet ( int age

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!