Thread: ArrayLists
View Single Post
Old Nov 10th, 2006, 3:58 PM   #8
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 936
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You could use a map to associate each letter with an array of numbers, as demonstrated below. This way there is no need to use if statements to extract values. You might also consider reading the values from a file rather than hard-coding them to make the program more flexible.

HashMap<Character, double[]> map = new HashMap<Character, double[]>();

map.put('A', new double[] { 142,83,66,0.06,0.076,0.035,0.058 });
map.put('R', new double[] { 98,93,95,0.07,0.106,0.099,0.085 });

double x = map.get('A')[0]; // Sets x to the first value in A (142)
double y = map.get('R')[2]; // Sets y to the third value in R (95)
titaniumdecoy is offline   Reply With Quote