There is similar question regarding this but in the answers the parameter types are used.
My question is that having a class what should be done to find out whether the method returned using reflection is overloaded or not?
Possible ways can be: 1) Looping to find the same method again
List<Method> overloaded = new ArrayList<Method>();
Method[] declaredMethods = A.class.getDeclaredMethods();
for(int i = 0; i < declaredMethods.length; i++){
for(int j = (i + 1); j < declaredMethods.length; j++){
if(declaredMethods[j].getName().equals(declaredMethods[i].getName())){
overloaded.add(declaredMethods[i]);
}
}
}
System.out.println(overloaded);
Is there some way to find out overloaded methods which has a better algorithmic complexity than this? Does some library provide the same functionality?