Sort list in ascending last name length by implementing the comparator interface through an anonymous class

Advertisements This is from the task: Select Comparator<> as the implemented interface. Inside the anonymous class, override the comparison method, namely compare. To get the last name from a string, split the string on a space using split and take the second part of the split. import java.util.stream.Collectors; public class Practicum { public static void… Read More Sort list in ascending last name length by implementing the comparator interface through an anonymous class

Can we create an anonymous inner class from a concrete class?

Advertisements There is something surprising in the following code. The ListCell class is not abstract, but we were able to create an anonymous class from it and override its method! How is this possible? ListCell<TodoItem> listCell = new ListCell<>() { @Override public void updateIndex(int i) { super.updateIndex(i); } }; >Solution : The concept of anonymous… Read More Can we create an anonymous inner class from a concrete class?