// A Java program to demonstrate that a method
// can return multiple values of same type by
// returning an array
class Test {
// Returns an array such that first element
// of array is a+b, and second element is a-b
static int[] getSumAndSub(int a, int b)
{
int[] ans = new int[2];
ans[0] = a + b;
ans[1] = a - b;
// returning array of elements
return ans;
}
// Driver method
public static void main(String[] args)
{
int[] ans = getSumAndSub(100, 50);
System.out.println("Sum = " + ans[0]);
System.out.println("Sub = " + ans[1]);
}
}
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();
}