Concours d’orthographe
Vous participez à un concours d’orthographe ! Pour vous aider, vous souhaitez créer un programme qui décompose les mots en lettres.
Cet exercice fait partie du cours
Java intermédiaire
Instructions
- Appliquez la bonne méthode pour récupérer la
lengthdetoSpell. - Utilisez le bon mot-clé pour démarrer une boucle for.
- Définissez la bonne valeur de départ pour
i: vous voulez commencer au premier caractère. - Écrivez la bonne méthode pour obtenir le
charà la positionidetoSpell.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
class Speller {
public static void main(String[] args) {
String toSpell = "conscientious";
// Choose the correct method on toSpell to retrieve its length
int wordLength = toSpell.____();
// Use the right keyword and put the starting correct value into i
____ (int i = ____; i < wordLength; i++) {
// Write down the correct method to retrieve the character at the ith position
System.out.println(toSpell.____(i));
}
}
}