I have an Array Of Integers that Contains several Colors; 0xFF000000. I have attempted to create a function that returns the Color from the Array based on the parameter of the function. The parameters will be numbers to the power of two; 2,4,8,16,32. How can I figure calculate which index from the array to get the color from based on the Parameter?
Function:
public static int getNumberColor(int number) {
int index = number % colors.length;
try {
return colors[index - 1];
} catch (Exception e) {
}
return colors[0];
}
What is the best way of doing this?