Here you can find the source of substring(String source, int startIndex)
public static String substring(String source, int startIndex)
//package com.java2s; public class Main { public static String substring(String source, int startIndex) { if (source == null) return null; int length = source.length(); if (startIndex < 0) startIndex = 0;/* w w w .j a v a 2s .com*/ if (length < startIndex) return ""; else return source.substring(startIndex); } public static String substring(String source, int startIndex, int endIndex) { if (source == null) return null; int length = source.length(); if (startIndex < 0) startIndex = 0; if (startIndex >= endIndex) return ""; else if (length < startIndex) return ""; else if (length < endIndex) return source.substring(startIndex, length - 1); else return source.substring(startIndex, endIndex); } }