Here you can find the source of substring(String str, int beginIndex, int endIndex)
Parameter | Description |
---|---|
str | The string. |
beginIndex | The begin index. |
endIndex | The end index. |
public static String substring(String str, int beginIndex, int endIndex)
//package com.java2s; //License from project: Open Source License public class Main { /**//from ww w . j a v a 2 s.c o m * Index safe substring operation. * * @param str The string. * @param beginIndex The begin index. * @param endIndex The end index. * @return The substring. */ public static String substring(String str, int beginIndex, int endIndex) { if (beginIndex < 0) { beginIndex = 0; } if (endIndex > str.length()) { endIndex = str.length(); } return str.substring(beginIndex, endIndex); } }