Suppose for some method I have a long set of parameters for the same type. I have a similar operation for each parameter (if they are not equal to zero). Suppose I have no control over the method signature, since the class implements the interface.
For example .. something simple. A set of string parameters ..
public void methodName(String param1, String param2, String param3, String param4){ //Only print parameters which are not null: if (param1 !=null) out.print(param1); if (param2 !=null) out.print(param2); if (param3 !=null) out.print(param3); if (param4 !=null) out.print(param4); }
Is there any way to iterate over the list of String parameters to check if they are null and print them out without having to refer to each variable separately?
source share