Does anyone know why this would happen?
When the first loop is excuted i get an ArrayIndexOutOfBounds
exception. But the second loopruns fine.
Code:public class Test{ public static void main(String[] args){ String s = new String("ABC"); char[] c = new char[s.length()]; int[] intArray = new int[25]; for(int i = 0; i < s.length(); i++){ c[s.charAt(i)]++; // array index out of bounds } for(int k = 0 ;k < s.length(); ++k){ c[s.charAt(k)]++; // runs fine } } }


Reply With Quote
Going from Access/Visual Basic
