I want to do something like this
List<Integer, String, String>
I want to be able to iteratively retrieve either of these three parameters. How can I go about it? Thanks
Note that when you are working with multiple parameters, the function call must have the same number of arguments as there are parameters, and the arguments must be passed in the same order.
In Python, by adding * and ** (one or two asterisks) to the head of parameter names in the function definition, you can specify an arbitrary number of arguments (variable-length arguments) when calling the function.
Luckily, you can write functions that take in more than one parameter by defining as many parameters as needed, for example: def function_name(data_1, data_2):
Parameters are specified after the method name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma.
What you need is a Tuple class:
public class Tuple<E, F, G> {
public E First;
public F Second;
public G Third;
}
Then you can iterate over the list of the tuple, and look at each entry in the tuple.
List<Tuple<Integer, String, String> listOfTuple;
for (Tuple<Integer, String, String> tpl: listOfTuple){
// process each tuple
tpl.First ... etc
}
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