I was reviewing some methods in the com.google.android.material.tabs.Tablayout when I came along with this method:
private static ColorStateList createColorStateList(int defaultColor, int selectedColor) {
int[][] states = new int[2][];
int[] colors = new int[2];
int i = 0;
states[i] = SELECTED_STATE_SET;
colors[i] = selectedColor;
int i = i + 1;
states[i] = EMPTY_STATE_SET;
colors[i] = defaultColor;
++i;
return new ColorStateList(states, colors);
}
How this method could be compiled with variable i being defined 2 times? It is part of the library everyone use.