I'm trying to use this to print out only part of an array. My array is 5 elements long - {6, 4, 2, 6, 2}
- and I'd like to print just {6, 4, 2, 6, 2}
. But using my current code, it's printing out [4, 2, 6, 2]
- indexes 1 through 4, not indexes 0 through 3. Why might this be happening?
String nucList = CCATT-AATGATCA-CAGTT
int[] counter = new int[5];
for (int i = 0; i < nucList.length(); i++) {
if (nucList.charAt(i) == 'A') {
} else if (nucList.charAt(i) == 'C') {
counter[0]++;
} else if (nucList.charAt(i) == 'G') {
counter[1]++;
} else if (nucList.charAt(i) == 'T') {
counter[2]++;
} else if (nucList.charAt(i) == '-') {
counter[3]++;
}
int[] counterNucs = Arrays.copyOfRange(counter, 0, 4);
filePrint.println("Nuc. Counts: " + Arrays.toString(counterNucs));
Thanks!
EDIT: This seems to even be an issue with the arrays in my project that should be printing in full as well. Should I post more of my code?