vendredi 9 septembre 2016

In Java, how to get all possiable return types?

In Java, method could be defined as following:

Object m(boolean b) {
    if (b) {
        return "123";
    } else {
        return new Integer(123);
    }
}

In this case, the return value of m could be either String or Integer in runtime. So is there any way to get all possible run time return types of a method?





Aucun commentaire:

Enregistrer un commentaire