Here you can find the source of substring(String str, int index, int length)
public static String substring(String str, int index, int length)
//package com.java2s; public class Main { public static String substring(String str, int index, int length) { if (str == null) { return null; }/*from ww w . ja va 2s .c om*/ int len = str.length(); if (index + length > len) { length = len - index; } return str.substring(index, length); } }