Java中的java.text.StringCharacterIterator类的clone()方法用于克隆此StringCharacterIterator。这意味着该方法将创建另一个StringCharacterIterator实例,其所有属性与此StringCharacterIterator相同,并将其返回。
用法:
public Object clone()
参数:此方法不接受任何参数。
返回值:此方法返回一个Object,它是此StringCharacterIterator的副本。
异常:此方法不引发任何异常。
程序:
// Java program to demonstrate
// the above method
import java.text.*;
import java.util.*;
public class StringCharacterIteratorDemo {
public static void main(String[] args)
{
String text = "GeeksForGeeks";
StringCharacterIterator
stringCharacterIterator
= new StringCharacterIterator(text);
System.out.println("Current StringCharacterIterator: "
+ stringCharacterIterator);
System.out.println("Cloned StringCharacterIterator: "
+ stringCharacterIterator.clone());
}
}
输出:
Current StringCharacterIterator: java.text.StringCharacterIterator@c11e1b98 Cloned StringCharacterIterator: java.text.StringCharacterIterator@c11e1b98
参考: https://docs.oracle.com/javase/9/docs/api/java/text/StringCharacterIterator.html#clone–
相关用法
- Java StringCharacterIterator next()用法及代码示例
- Java StringCharacterIterator first()用法及代码示例
- Java StringCharacterIterator last()用法及代码示例
- Java StringCharacterIterator getEndIndex()用法及代码示例
- Java StringCharacterIterator getIndex()用法及代码示例
- Java StringCharacterIterator previous()用法及代码示例
- Java StringCharacterIterator setText()用法及代码示例
- Java StringCharacterIterator current()用法及代码示例
- Java StringCharacterIterator equals()用法及代码示例
- Java StringCharacterIterator getBeginIndex()用法及代码示例
- Java StringCharacterIterator hashCode()用法及代码示例
- Java StringCharacterIterator setIndex()用法及代码示例
- Java Properties clone()用法及代码示例
- Java Locale clone()用法及代码示例
- Java SimpleTimeZone clone()用法及代码示例
注:本文由纯净天空筛选整理自ShubhamMaurya3大神的英文原创作品 StringCharacterIterator clone() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。