I am trying to solve competitive programming questions using Java. In questions involving the use of arrays, I will have to write my programs such that the array can hold a large number of values(beyond the range of int) and also each array element is also beyond the int range. So I am using long for this. But if I try accessing say
a[i++] = b[j++];
where i & j & a& b are all of long type, I get the following error:
error: possible loss of precision
for the index access.
How do I access such elements? I tried typecast of long to int for the index values, and the error goes away, but won't that affect the precision too?
variable declarations are as follows:
long numTest = in.nextLong();
long [] sizes = new long[numTest];