I am trying to create an int[] from a string that I get from my getter (9,10,11,12,13,14,15,16). I've verified that the string is passed in the format above. However when I loop to through the Tokenizer it skips values in my string. Also my new Array values are all set to 0. This is my output. Would someone point me in the right direction. Thanks
System.out.println("Token Value = " + st.nextToken()); cArray[i] = Integer.parseInt(st.nextToken());
lines have bug.
You are calling nextToken() twice. So it seems like it is skipping tokens.
If you want to print you have to do something like, String temp = stk.nextToken(); System.out.println("Token value="+temp); cArray[i] = Integer.parseInt(temp);
Maulin nailed it. And the reason your array output shows all zeros is that you loop through the array with the index "j" but print the value at position "i" which is one past your last valid value. If you only fix the first problem, you'll get an ArrayIndexOutOfBoundsException.