Here you can find the source of rangeDivide(Integer begin, Integer end, Integer divideNum)
public static Integer[][] rangeDivide(Integer begin, Integer end, Integer divideNum)
//package com.java2s; //License from project: Open Source License public class Main { public static Integer[][] rangeDivide(Integer begin, Integer end, Integer divideNum) { if (begin == null || end == null || begin >= end || divideNum == null || divideNum <= 0) { return null; }//from w w w. j a v a 2 s . c om Integer[][] ranges = new Integer[divideNum][2]; int spread = end - begin; for (int i = 1; i < divideNum; i++) { ranges[i - 1][0] = spread / divideNum * (i - 1) + begin; ranges[i - 1][1] = spread / divideNum * i + begin; } ranges[divideNum - 1][0] = spread / divideNum * (divideNum - 1) + begin; ranges[divideNum - 1][1] = spread + begin; return ranges; } }