“Quelle méthode est utilisée pour obtenir la position d'index d'un caractère d'une chaîne en java” Réponses codées

caractère à l'index de String Java

String str = "Grepper";
char ch = str.charAt(0);
//ch is assigned the value of G
Disgusted Dove

Quelle méthode est utilisée pour obtenir la position d'index d'un caractère d'une chaîne en java

// If you want to get the index position of a character in a String, use this method:
.charAt( /*Args int*/ )
// Here's a practial example:
String str = "Grepper";
char ch = str.charAt(0);

// If you want to get the index position of a word/char in a string(a Phrase/Sentence), you could use this method:
.indexOf( /*Args Str*/ )
// Here's a practial example:
String myStr = "This is just an example Sentence";
System.out.println(myStr.indexOf("example"));
Zeerex23

Réponses similaires à “Quelle méthode est utilisée pour obtenir la position d'index d'un caractère d'une chaîne en java”

Questions similaires à “Quelle méthode est utilisée pour obtenir la position d'index d'un caractère d'une chaîne en java”

Plus de réponses similaires à “Quelle méthode est utilisée pour obtenir la position d'index d'un caractère d'une chaîne en java” dans Java

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code