Hi is there any way for me to pass variable arguments to a method?
public void unMarshalling(String type, int number){
}
So that instead of int, I can make my method such that I am able to pass in float, double, string and other primitive data types(+ string). Any simple examples will be deeply appreciated! Thanks alot!
Try this:
public void unMarshalling(Object ... params) {
}
Now you can pass any number of arguments of any type:
unMarshalling(23);
unMarshalling("Hello");
unMarshalling("Hello", 45.3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With