Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

multiple return values in function java

Tuple2<Coordinates, Double> getMostDistantPoint(List<Coordinates> coordinatesList, 
                                                       Coordinates target) {

    return coordinatesList.stream()
      .map(coor -> new Tuple2<>(coor, coor.calculateDistance(target)))
      .max((d1, d2) -> Double.compare(d1.getSecond(), d2.getSecond())) // compare distances
      .get();
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #multiple #return #values #function #java
ADD COMMENT
Topic
Name
2+2 =