⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e307. iterating the characters of a string.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
CharacterIterator it = new StringCharacterIterator("abcd");
    
    // Iterate over the characters in the forward direction
    for (char ch=it.first(); ch != CharacterIterator.DONE; ch=it.next()) {
        // Use ch ...
    }
    
    // Iterate over the characters in the backward direction
    for (char ch=it.last(); ch != CharacterIterator.DONE; ch=it.previous()) {
        // Use ch ...
    }
    
    // Other methods
    char ch = it.first();      // a
    ch = it.current();         // a
    ch = it.next();            // b
    ch = it.current();         // b
    ch = it.last();            // d
    int pos = it.getIndex();   // 3
    ch = it.next();            // DONE
    pos = it.getIndex();       // 4
    ch = it.previous();        // d
    ch = it.setIndex(1);       // b
    
    // Change the characters
    ((StringCharacterIterator)it).setText("efgh");
    ch = it.current();         // e
    
    // Create an iterator on a substring (efgh)
    int begin = 5;
    int end = 9;
    pos = 6;
    it = new StringCharacterIterator("abcd efgh ijkl", begin, end, pos);
    ch = it.current();         // f
    ch = it.last();            // h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -