Java中的java.text.StringCharacterIterator类的equals()方法用于检查此StringCharacterIterator与指定的StringCharacterIterator是否相等。此方法采用StringCharacterIterator实例,并将其与此StringCharacterIterator进行比较,并返回一个表示该实例的布尔值。
用法:
public boolean equals(Object obj)
参数:此方法接受参数obj,它是StringCharacterIterator,将与该StringCharacterIterator进行相等性检查。
返回值:此方法返回一个布尔值,该布尔值指示此StringCharacterIterator是否等于指定的Object。
异常:此方法不引发任何异常。
程序:
// Java program to demonstrate
// the above method
import java.text.*;
import java.util.*;
public class StringCharacterIteratorDemo {
public static void main(String[] args)
{
StringCharacterIterator sci1
= new StringCharacterIterator(
"GeeksforGeeks");
System.out.println("StringCharacterIterator 1: "
+ sci1);
StringCharacterIterator sci2
= new StringCharacterIterator(
"Geeks for Geeks");
System.out.println("StringCharacterIterator 2: "
+ sci2);
StringCharacterIterator sci3
= (StringCharacterIterator)sci1
.clone();
System.out.println("StringCharacterIterator 3: "
+ sci3);
System.out.println("Comparing DFS 1 and DFS 2: "
+ sci1.equals(sci2));
System.out.println("Comparing DFS 2 and DFS 3: "
+ sci2.equals(sci3));
System.out.println("Comparing DFS 1 and DFS 3: "
+ sci1.equals(sci3));
}
}
输出:
StringCharacterIterator 1: java.text.StringCharacterIterator@bd43b778 StringCharacterIterator 2: java.text.StringCharacterIterator@ac5740a8 StringCharacterIterator 3: java.text.StringCharacterIterator@bd43b778 Comparing DFS 1 and DFS 2: false Comparing DFS 2 and DFS 3: false Comparing DFS 1 and DFS 3: true
相关用法
- Java StringCharacterIterator first()用法及代码示例
- Java StringCharacterIterator last()用法及代码示例
- Java StringCharacterIterator next()用法及代码示例
- Java StringCharacterIterator getIndex()用法及代码示例
- Java StringCharacterIterator setIndex()用法及代码示例
- Java StringCharacterIterator setText()用法及代码示例
- Java StringCharacterIterator getEndIndex()用法及代码示例
- Java StringCharacterIterator clone()用法及代码示例
- Java StringCharacterIterator previous()用法及代码示例
- Java StringCharacterIterator getBeginIndex()用法及代码示例
- Java StringCharacterIterator current()用法及代码示例
- Java StringCharacterIterator hashCode()用法及代码示例
- Java Map equals()用法及代码示例
- Java Set equals()用法及代码示例
- Java Path equals()用法及代码示例
注:本文由纯净天空筛选整理自ShubhamMaurya3大神的英文原创作品 StringCharacterIterator equals() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。