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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。