import java.lang.reflect.Method; import java.util.Arrays; import java.util.Comparator; import java.util.function.Function; public class FieldsOrderingTest { public static void main(String[] args) { Method[] declaredMethods = getSorted(Child.class, Class::getDeclaredMethods, Method::getName); for (Method declaredMethod : declaredMethods) { System.out.println(declaredMethod.getName() + " - " + declaredMethod.getReturnType().getName()); } } private static E[] getSorted(S source, Function elements, Function name) { E[] result = elements.apply(source); // This comparator compares methods by their names, which are all the // same => does not sort anything. Arrays.sort(result, Comparator.comparing(name)); return result; } // Bunch of classes using generics. static class Child extends Parent { @Override public ChildProperty getProperty() { return null; } } abstract static class Parent { abstract public T getProperty(); } static class ChildProperty extends ParentProperty { } abstract static class ParentProperty { } }