I don't seem to be able to access Arrays.copyOfRange in my Android project in Eclipse Indigo 3.7.1 On Ubuntu 11.10.
My JRE is java-6-openjdk which I thought included Arrays.copyOfRange
For example, if I have this code:
int[] debug = new int[5];
int[] x = Arrays.copyOfRange(debug,0,4);
Eclipse tells me
The method
copyOfRange(int[], int, int)is undefined for the typeArrays
I don't understand because the Android reference Arrays includes this method for Arrays.
Any ideas?
The method Arrays.copyOfRange() wasn't introduced until API level 9. Make sure you are using that as the minimum SDK.
Also, you are indexing incorrectly. In java if you have an array of size 5 the indices range from 0->4
Change your code to this:
int[] debug = new int[5];
int[] x = Arrays.copyOfRange(debug,0,4); // use 4 instead of 5
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With