T
TrevorBoydSmith
As the title says... I am confused about this. I wish to index into an
array with a primitive datatype long. But the compiler will not
compile. It only accepts primitive datatype int to index into an
array!
---------------------------
Code snippet:
---------------------------
public class errorTest1{
public static void main(String args[]){
long n = 5;
int[] array = new int[1024];
n = (long)array[n];
}
}
---------------------------
end Code snippet:
---------------------------
ERROR -->
Type mismatch: cannot convert from long to
int error_test1 errorTest1.java line 7
Am i correct in assuming that you can not index an array unless it is
of datatype primitive int???
I ask about this because this pertains to code that I am porting from
C. In C you can index with primitive datatype long.
array with a primitive datatype long. But the compiler will not
compile. It only accepts primitive datatype int to index into an
array!
---------------------------
Code snippet:
---------------------------
public class errorTest1{
public static void main(String args[]){
long n = 5;
int[] array = new int[1024];
n = (long)array[n];
}
}
---------------------------
end Code snippet:
---------------------------
ERROR -->
Type mismatch: cannot convert from long to
int error_test1 errorTest1.java line 7
Am i correct in assuming that you can not index an array unless it is
of datatype primitive int???
I ask about this because this pertains to code that I am porting from
C. In C you can index with primitive datatype long.