Java, non fixed parameters for method -
I'm beginning to get started on Java:
public zero method (int Param1, int param2, int param3, int param4)
Depends on the circumstances, sometimes I need to [Param1], or pass the parameter of [param2, param4] For, it depends on an XML setting. But it is not easy to pass the bus (0, desired value 1, desired value2, 0) - to define the parameter name and its value, the best one has to pass an associate array I have heard that this type of work is reflection Is done with.
You can pass an array:
Public Zero Law (Int [] params)
It is still necessary that you allocate an array of n elements, where n is the maximum number of maximum possible parameters, and can be unusable for large N It is also important for you to have a default blank value (such as 0), which tells you that there is no value for a fixed position in the array.
int [] Parameters = new int [13]; Consultation [0] = value1; Paramage [3] = Value 4; Param [4] = value 5; Law (params);
Or you can pass a list:
public zero method (list & lt; integer & gt; parameter)
or you can pass a map:
public zero method (map & lt; integer, integer> parameter)
if You have the most efficient optional parameters, and you want to pass some of them:
map map = new hashmap
Comments
Post a Comment