Concours d'orthographe
Vous participez à un concours d'orthographe! Pour vous aider, vous voulez créer un programme qui décompose les mots en lettres.
Cette activité fait partie du cours
Java intermédiaire
Instructions de l’exercice
- 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 partir du premier caractère. - Écrivez la bonne méthode pour obtenir le
charà laie position detoSpell.
Exercice interactif pratique
Essayez cet exercice en complétant ce code d’exemple.
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));
}
}
}