Bắt đầu ngayBắt đầu miễn phí

Spelling bee

You have entered a spelling competition! To help you, you want to make a program which will decompose the words into letters.

Bài tập này là một phần của khóa học

Intermediate Java

Xem khóa học

Hướng dẫn bài tập

  • Apply the correct method to retrieve the length of toSpell.
  • Use the correct keyword to start a for loop.
  • Set the correct starting value for i - you want to start from the first character.
  • Write the correct method to get the character at the ith position of toSpell.

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

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));
    }
  }
}
Chỉnh sửa và Chạy Mã