Java String Sub String substring(String str, int start)

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

Description

substring

License

Apache License

Declaration

public static String substring(String str, int start) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final String EMPTY = "";

    public static String substring(String str, int start) {
        if (str == null) {
            return null;
        }//from   w  w  w.ja va 2  s.c  om

        // handle negatives, which means last n characters
        if (start < 0) {
            start = str.length() + start; // remember start is negative
        }

        if (start < 0) {
            start = 0;
        }
        if (start > str.length()) {
            return EMPTY;
        }

        return str.substring(start);
    }
}

Related

  1. subString(String str, int len)
  2. subString(String str, int num, String token)
  3. substring(String str, int off, int len)
  4. subString(String str, int offset, int leng)
  5. substring(String str, int start)
  6. substring(String str, int start)
  7. subString(String str, int start, int end)
  8. substring(String str, int start, int end)
  9. substring(String str, int start, int end)