jeudi 4 janvier 2018

How to differentiate between Variable length v/s Array type in Java

I am using reflection to create dynamic examples for my functions written under one class.

i.e below are my functions :

public void doSomething(int... args)
{
...
}
// Example to generate : doSomething(1,2,3,4,5);

public void doSomething2(int[] argsAsArray)
{
...
}
// Example to generate : doSomething2(new int[]{1,2,3,4,5})

My problem is, I am not able to differentiate between the types of Variable length v/s Array type of argument.

Is there a way that using which I can determine whether parameter type is Variable length or an Array ?





Aucun commentaire:

Enregistrer un commentaire