méthode substring Java ()
substring () retourne une sous-chaîne d'une chaîne.
grammaire
public String substring(int beginIndex) 或 public String substring(int beginIndex, int endIndex)
Paramètres
beginIndex - l'indice de début (y compris).
endIndex - l'index de fin (non inclus).
Valeur de retour
Substring.
Exemples
public class Test { public static void main(String args[]) { String Str = new String("www.w3big.com"); System.out.print("返回值 :" ); System.out.println(Str.substring(4) ); System.out.print("返回值 :" ); System.out.println(Str.substring(4, 10) ); } }
Les résultats de l'exécution du programme ci-dessus:
返回值 :w3big.com 返回值 :w3big