Java String Sub String substring(String string, int init, int end)

Here you can find the source of substring(String string, int init, int end)

Description

Extrae una subcadena, donde los indices pueden ser negativos

License

Open Source License

Parameter

Parameter Description
string Cadena
init Inicio
end Fin

Return

Subcadena

Declaration

public static String substring(String string, int init, int end) 

Method Source Code

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

public class Main {
    /**/*  ww w .  ja  va2s .  com*/
     * Extrae una subcadena, donde los indices pueden ser negativos
     *
     * @param string Cadena
     * @param init Inicio
     * @param end Fin
     * @return Subcadena
     */
    public static String substring(String string, int init, int end) {
        if (init < 0) {
            init += string.length();
        }
        if (end < 0) {
            end += string.length();
        }
        return string.substring(init, end);
    }
}

Related

  1. substring(String str, int toCount)
  2. substring(String str, int toCount, String more)
  3. substring(String str, String delim)
  4. subString(String string, int beginIndex, int length)
  5. subString(String string, int index)
  6. substring(String string, int maxChars, String suffix)
  7. substring(String string, int start, int length)
  8. substring(String string, String beginning, String end)
  9. subString(String string, String inizio, String fine)