Here you can find the source of substring(final String string, int fromIndex, int toIndex)
public static String substring(final String string, int fromIndex, int toIndex)
//package com.java2s; //License from project: Open Source License public class Main { public static String substring(final String string, int fromIndex, int toIndex) { final int len = string.length(); if (fromIndex < 0) { fromIndex += len;/* w w w. j a v a 2 s. c om*/ if (toIndex == 0) { toIndex = len; } } if (toIndex < 0) { toIndex += len; } if (fromIndex < 0) { fromIndex = 0; } if (toIndex > len) { toIndex = len; } if (fromIndex >= toIndex) { return ""; } return string.substring(fromIndex, toIndex); } }