I am a newbie in programming and I need some advice on storing of multiple types of data together.
My method takes in a String Array as parameter. This string array basically is an array of Chemical elements.
I iterate through each element of the array and call another method that takes in each chemical element as a parameter and calculates 4 values.
Now before I pass the next element as the function parameter, I need to store the 4 values calculated by the method for that corresponding element.
For this reason, I think I may need an ArrayList ( I could be completely wrong though) which stores the first element as a string type i.e the Element Name, and the remaining 4 double values.
Alternatively, I can also create a double array of size 4 to store the 4 calculated values and call each array by the element name
for example,
I dont know how to programmaticall y name the array according to each element of the initial string array.
Please help me and excuse my lack of knowledge if this is a well documented scenario but I simply didn't knew where to look.
Thanks.
My method takes in a String Array as parameter. This string array basically is an array of Chemical elements.
Code:
String[] elements = { Calcium, Potassium, Magnesium, Sodium}
Code:
for (int i = 0; i < elements.Length; i++) {[INDENT]...some lines of code GetDerivedPropertyValues(Calcium);[/INDENT]}
For this reason, I think I may need an ArrayList ( I could be completely wrong though) which stores the first element as a string type i.e the Element Name, and the remaining 4 double values.
Alternatively, I can also create a double array of size 4 to store the 4 calculated values and call each array by the element name
for example,
Code:
double[] calcium = new double[4]
Please help me and excuse my lack of knowledge if this is a well documented scenario but I simply didn't knew where to look.
Thanks.
Comment