English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Java possède de nombreuses méthodes String qui nous permettent d'utiliser les chaînes. Dans cette page de référence, vous trouverez toutes les méthodes de chaînes disponibles en Java. Par exemple, si vous avez besoin de trouver la longueur d'une chaîne, utilisez la méthode length().
méthode | description |
---|---|
split() | divise la chaîne en une chaîne spécifiée (expression régulière) |
compareTo() | compare deux chaînes par ordre alphabétique |
compareToIgnoreCase() | compare deux chaînes, en ignorant la casse |
length() | retourne la longueur de la chaîne |
replace() | remplace tous les caractères correspondants dans la chaîne/texte |
replaceAll() | remplace tous les sous-chaines correspondant au modèle régulier |
substring() | retourne le sous-chaine de la chaîne donnée |
equals() | compare deux chaînes |
equalsIgnoreCase() | compare deux chaînes, en ignorant la casse |
contains() | vérifie si la chaîne contient un sous-chaine |
indexOf() | retourne le caractère spécifié dans la chaîne/l'index de la première apparition du sous-chaine. |
trim() | supprime tout espace en tête et en queue |
charAt() | retourne le caractère à l'indice donné |
toLowerCase() | Convert the characters in the string to lowercase |
concat() | Concatenate two strings and return |
valueOf() | Return the string representation of the value |
matches() | Check if the string matches the given regular expression |
startsWith() | Check if the string starts with the given string |
endsWith() | Check if the string ends with the given string |
isEmpty() | Check if the string is empty |
intern() | Return the normalized representation of the string |
getBytes() | Encode the string into a byte sequence |
contentEquals() | Check if the string is equal to charSequence (character sequence) |
hashCode() | Return the hash code of the string |
join() | Join the given strings with a delimiter |
replaceFirst() | Replace the first matching substring |
subSequence() | Return the substring of the string |
toCharArray() | Convert the string to a char array |
format() | Return the formatted string |