Here you can find the source of substring(String str, int start)
public static String substring(String str, int start)
//package com.java2s; //License from project: Open Source License public class Main { public static String substring(String str, int start) { if (str == null) return null; if (start < 0) start = str.length() + start; if (start < 0) start = 0;/* w w w . ja v a 2 s . c o m*/ return (start > str.length()) ? "" : str.substring(start); } public static String substring(String str, int start, int end) { if (str == null) return null; if (end < 0) end = str.length() + end; if (start < 0) start = str.length() + start; if (end > str.length()) end = str.length(); if (start > end) return ""; if (start < 0) start = 0; if (end < 0) end = 0; return str.substring(start, end); } public static int length(String str) { return str == null ? 0 : str.length(); } }