शुरू करेंमुफ़्त में शुरू करें

Spelling bee

आप एक स्पेलिंग प्रतियोगिता में शामिल हुए हैं! इसमें मदद के लिए, आप ऐसा प्रोग्राम बनाना चाहते हैं जो शब्दों को अक्षरों में तोड़ दे.

यह अभ्यास पाठ्यक्रम का हिस्सा है

इंटरमीडिएट Java

पाठ्यक्रम देखें

अभ्यास निर्देश

  • toSpell की length प्राप्त करने के लिए सही method लागू करें.
  • for loop शुरू करने के लिए सही कीवर्ड इस्तेमाल करें.
  • i के लिए सही शुरुआती मान सेट करें — आपको पहले character से शुरू करना है.
  • toSpell की ith position पर मौजूद character पाने के लिए सही method लिखें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

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));
    }
  }
}
कोड संपादित करें और चलाएँ