Если вам нужно написать 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()); } }
➡️Главная проблема — понять, от чего отнимать, чтобы порядок был правильным. Правильный ответ с первого раза получается редко, и часто мы замечаем ошибку уже после запуска кода.
Теперь это не нужно. Можно использовать ссылки на методы:
Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”
Mr. Durov launched Telegram in late 2013 with his brother, Nikolai, just months before he was pushed out of VK, the Russian social-media platform he founded. Mr. Durov pitched his new app—funded with the proceeds from the VK sale—less as a business than as a way for people to send messages while avoiding government surveillance and censorship.