Passing an Integer or String array as an argument in java
In java, you can only pass data defined in a method. A way to do this might be to use Object as an argument. Alternatively, you can create many methods with the same name, but accept different arguments. Example:
public void example(String str, Object obj){ /* code */ }
When using Object, you need to make sure it is of type, so you are not trying to use an integer as a string array.
I'm pretty sure using Object is not the best way to go and you should use multiple methods with different arguments.
source to share
How do you want the second object to be like any array of datatypes you can do something like this
public void _methodName(String arg1,Object[] arg2)
As String, Integer, Float, Boolean all inherit from java.lang.Object
, you can just pass as the second argument and pass the argument (String, Int, .... etc) whatever you want. Object[]
source to share