lundi 31 août 2015

Is reflection execute the method in sequence order?

I have a class file, and I just want to get the list of methods name in that class and print it o/p console.

Just assume that I have following methods in Test1 class

public class Test1{

public static void test1()
{
//some code
}

public static void test2()
{
//some code
}

public static void test3()
{
//some code here.
}
}

I just need to call all the above methods from another class in the specific order.

Like test1() first, and second test2() and followed by test3();

What I did like I just created

 Method[] methodarray=Test1.getMethods();
    if(methodarray.getName().startWith("test"))
    {
    sysout(methodarray.getName())
    }

The above code print the method in specific order first time but not always. some times it prints 3rd method first and 1method seconds, and finally 2 method.

Can anybody tell me the reason?, and how to resolve this?.

-Sasi





Aucun commentaire:

Enregistrer un commentaire