java 反射取方法名 能自己定排序?
Classcls=Class.forName("User");Method[]mothods=cls.getDeclaredMethods();Stringmeth[]=...
Class cls=Class.forName("User");
Method[] mothods=cls.getDeclaredMethods();
String meth[] = new String[fieldlist.length];
int count=0;
for (Method method : mothods) {
if(method.getName().subSequence(0, 3).equals("get"))
{
meth[count]=method.getName();
System.out.println(method.getName());
count++;
}
} 展开
Method[] mothods=cls.getDeclaredMethods();
String meth[] = new String[fieldlist.length];
int count=0;
for (Method method : mothods) {
if(method.getName().subSequence(0, 3).equals("get"))
{
meth[count]=method.getName();
System.out.println(method.getName());
count++;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询