Java String Sub String substring(String str, int beginIndex, int endIndex)

Here you can find the source of substring(String str, int beginIndex, int endIndex)

Description

substring

License

Open Source License

Declaration

public static String substring(String str, int beginIndex, int endIndex) 

Method Source Code

//package com.java2s;

public class Main {

    public static String substring(String str, int beginIndex, int endIndex) {
        if (str == null)
            return "";
        int length = str.length();
        endIndex = (endIndex < 0) ? 0 : endIndex;
        endIndex = (endIndex > length) ? length : endIndex;
        beginIndex = (beginIndex < 0) ? 0 : beginIndex;
        beginIndex = (beginIndex > endIndex) ? endIndex : beginIndex;
        str = str.substring(beginIndex, endIndex);
        return str;
    }// w  w w .  j a  va 2  s.  co m
}

Related

  1. subString(String src, String start, String to)
  2. subString(String src, String start, String to)
  3. subString(String srcStr, int subLen)
  4. substring(String str, char pattern)
  5. substring(String str, int beginIndex)
  6. substring(String str, int beginIndex, int endIndex)
  7. subString(String str, int beginIndex, int endIndex)
  8. substring(String str, int beginIndex, int len)
  9. subString(String str, int end)