I want to calculate the sum of all odd array indexes, but I\'m having some trouble finding the right way to do it.
Here\'s my code so far:
String id
Just edited your code:
String id = "9506265088085"; int[] intArray = new int[id.length()]; int sum = 0; for (int i = 0; i < intArray.length; i++) { if (i%2!=0) { sum += Integer.parseInt(String.valueOf(id.charAt(i)); }} System.out.println(sum);