Here you can find the source of substring(String str, int beginIndex, int endIndex)
public static String substring(String str, int beginIndex, int endIndex)
//package com.java2s; public class Main { public static String substring(String str, int beginIndex, int endIndex) { if (str == null) return ""; int length = str.length(); endIndex = (endIndex < 0) ? 0 : endIndex; endIndex = (endIndex > length) ? length : endIndex; beginIndex = (beginIndex < 0) ? 0 : beginIndex; beginIndex = (beginIndex > endIndex) ? endIndex : beginIndex; str = str.substring(beginIndex, endIndex); return str; }// w w w . j a va 2 s. co m }