I have a list which contains all setters of my POJO class.
public static void main(String[] args) throws Exception {
Method[] publicMethods = SampleClass.class.getMethods();
List<Method> setters = new ArrayList<>();
for (Method method : publicMethods){
if (method.getName().startsWith("set") && method.getParameterCount() == 1) {
setters.add(method);
}
}
}
In documentation order of Method list is not guaranteed. My question is how can i sort my list of setters alphabetically?