Если вам нужно написать Comparator для сортировки объектов по возрастанию, обычно он выглядит так:
public class ByScoreComparator implements Comparator<User> {
@Override public int compare(User u1, User u2) { return (int) signum(u2.getAge() - u1.getAge()); } }
➡️Главная проблема — понять, от чего отнимать, чтобы порядок был правильным. Правильный ответ с первого раза получается редко, и часто мы замечаем ошибку уже после запуска кода.
Теперь это не нужно. Можно использовать ссылки на методы:
Если вам нужно написать Comparator для сортировки объектов по возрастанию, обычно он выглядит так:
public class ByScoreComparator implements Comparator<User> {
@Override public int compare(User u1, User u2) { return (int) signum(u2.getAge() - u1.getAge()); } }
➡️Главная проблема — понять, от чего отнимать, чтобы порядок был правильным. Правильный ответ с первого раза получается редко, и часто мы замечаем ошибку уже после запуска кода.
Теперь это не нужно. Можно использовать ссылки на методы:
Telegram is a cloud-based instant messaging service that has been making rounds as a popular option for those who wish to keep their messages secure. Telegram boasts a collection of different features, but it’s best known for its ability to secure messages and media by encrypting them during transit; this prevents third-parties from snooping on messages easily. Let’s take a look at what Telegram can do and why you might want to use it.
Dump Scam in Leaked Telegram Chat
A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.