Skip to content

Instantly share code, notes, and snippets.

@drulabs
Last active August 7, 2018 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drulabs/676b4f2243b1e9e88294101e6d04d586 to your computer and use it in GitHub Desktop.
Save drulabs/676b4f2243b1e9e88294101e6d04d586 to your computer and use it in GitHub Desktop.
Find customer with minimum balance
// JAVA WAY - Who has minimum balance
Customer minBalanceCustomer = Collections.min(
customers, (o1, o2) -> (int) (o1.getBalance() - o2.getBalance())
);
// KOTLIN WAY - Who has minimum balance
val minBalanceCustomer = customers.minBy { it.balance }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment