main.java

来自「java的经典例子」· Java 代码 · 共 34 行

JAVA
34
字号
import java.text.StringCharacterIterator;class Main {    public static void main(String args[]) {        String str = "Hello world";        // create string character iterator        StringCharacterIterator iter = new StringCharacterIterator(str, 6);        printValues(iter);         // prints '6' and 'w'        // create a clone         StringCharacterIterator iterCopy =             (StringCharacterIterator)iter.clone();         printValues(iterCopy);     // prints '6' and 'w'        if(iter.equals(iterCopy)) {            System.out.println("Copy is equal to original");        } else {            System.out.println("Copy is not equal to original");        }        // compute hashcode        int hc = iter.hashCode();        System.out.println("Hash code is: " + hc);    }    public static void printValues(StringCharacterIterator it) {        System.out.println(it.getIndex());        System.out.println(it.current());    }}

⌨️ 快捷键说明

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