Java String Sub String substr(String s, int start, int end)

Here you can find the source of substr(String s, int start, int end)

Description

substr

License

Open Source License

Declaration

public static String substr(String s, int start, int end) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String substr(String s, int start, int end) {
        int length = s.length();
        if (start < 0)
            start += length;/*from  w  w  w .j  a  v a 2s .  c om*/
        if (end < start)
            end += length;
        end = Math.min(length, end);
        return s.substring(start, end);
    }
}

Related

  1. substr(byte[] i_Value, int i_BeginIndex)
  2. substr(String s, String sub, boolean before)
  3. substr(String src, int beginIndex, int endIndex)
  4. subStr(String src, int len)
  5. substr(String src, int nStart, int nLen)