Here you can find the source of Sum(Object in, int min, int max)
public static final int Sum(Object in, int min, int max)
//package com.java2s; //License from project: Open Source License public class Main { public static final int Sum(Object in, int min, int max) { // END BOOL ONLY */ if (in instanceof boolean[]) { boolean[] inn = (boolean[]) in; if (max >= inn.length) max = inn.length - 1;/*from w w w . j a va 2 s. c om*/ /* NO BOOL boolean out = 0; for ( int i = min; i <= max; i ++ ) out += inn[ i ]; return out; END NO BOOL */ // BOOL ONLY int out = 0; for (int i = min; i <= max; i++) out += inn[i] ? 1 : 0; return out; // END BOOL ONLY */ } else { /* NO BOOL boolean out = 0; END NO BOOL */ // BOOL ONLY int out = 0; // END BOOL ONLY */ for (int i = 0, s = ((Object[]) in).length; i < s; i++) out += Sum(((Object[]) in)[i], min, max); return out; } } public static final int Sum(Object in) { // END BOOL ONLY */ if (in instanceof boolean[]) return Sum((boolean[]) in, 0, ((boolean[]) in).length); else { /* NO BOOL boolean out = 0; END NO BOOL */ // BOOL ONLY int out = 0; // END BOOL ONLY */ for (int i = 0, s = ((Object[]) in).length; i < s; i++) out += Sum(((Object[]) in)[i]); return out; } } }