始める無料で始める

スペリングビー

あなたはスペリングのコンテストに参加しています! その助けとして、単語を文字ごとに分解するプログラムを作りたいと考えています。

この演習はコースの一部です

中級 Java

コースを見る

演習の手順

  • toSpelllength を取得する正しいメソッドを使ってください。
  • for ループを開始する正しいキーワードを使ってください。
  • i の開始値を正しく設定してください。最初の文字から始めます。
  • toSpelli 番目の位置にある char を取得する正しいメソッドを書いてください。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

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));
    }
  }
}
コードを編集して実行