Here you can find the source of sliceLength(int start, int stop, long step)
public static final int sliceLength(int start, int stop, long step)
//package com.java2s; public class Main { /**// www .j a v a 2 s . co m * Make step a long in case adding the start, stop and step together overflows an int. */ public static final int sliceLength(int start, int stop, long step) { int ret; if (step > 0) { ret = (int) ((stop - start + step - 1) / step); } else { ret = (int) ((stop - start + step + 1) / step); } if (ret < 0) { return 0; } return ret; } }