The longest rivers

Report a typo

There is a class which represents rivers using name and length.

class River {
    private final String name;
    private final long length;
    
    // a constructor and getters
}

There is also a sorted (descending) list of six the longest rivers on Earth.

List<River> rivers = List.of(
        new River("Nile", 6650),
        new River("Amazon", 6400),
        new River("Yangtze", 6300),
        new River("Mississippi", 6275),
        new River("Yenisei", 5539),
        new River("Huang He", 5464)
);

You need to match the following statements and their results.

Match the items from left and right columns
rivers.stream().takeWhile(r -> r.getLength() < 6000).count()
rivers.stream().takeWhile(r -> r.getLength() > 6000).count()
rivers.stream().dropWhile(r -> r.getLength() < 6000).count()
rivers.stream().dropWhile(r -> r.getLength() > 6000).count()
2
0
4
6
___

Create a free account to access the full topic