java.text.ChoiceFormat类的equals()方法用于在两个ChoiceFormat对象之间进行比较,并提供有关比较的布尔值。
用法:
public boolean equals(Object obj)
参数:此方法将obj作为参数,这是另一个ChoiceFormat对象用于比较。
返回值:如果两个选择格式对象都相等,则此方法返回true,否则返回false。
下面是说明equals()方法的示例:
示例1:
// Java program to demonstrate equals() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing ChoiceFormat
ChoiceFormat cf1
= new ChoiceFormat(
"4#wed| 5#thu | 6#fri | 7#sat");
// creating and initializing ChoiceFormat
ChoiceFormat cf2
= new ChoiceFormat(
"4#wed| 5#thu | 6#fri | 7#sat");
// compare cf1 and cf2
// using equals() method
boolean status = cf1.equals(cf2);
// display the result
if (status)
System.out.println("Both ChoiceFormat"
+ " objects are equal");
else
System.out.println("Both ChoiceFormat "
+ "objects are not equal");
}
}
输出:
Both ChoiceFormat objects are equal
示例2:
// Java program to demonstrate equals() method
import java.text.*;
import java.util.*;
import java.io.*;
public class GFG {
public static void main(String[] argv)
{
// creating and initializing ChoiceFormat
ChoiceFormat cf1
= new ChoiceFormat(
"1#sun| 2#mon | 3#tues | 4#wed");
// creating and initializing ChoiceFormat
ChoiceFormat cf2
= new ChoiceFormat(
"4#wed| 5#thu | 6#fri | 7#sat");
// compare cf1 and cf2
// using equals() method
boolean status = cf1.equals(cf2);
// display the result
if (status)
System.out.println("Both ChoiceFormat"
+ " objects are equal");
else
System.out.println("Both ChoiceFormat "
+ "objects are not equal");
}
}
输出:
Both ChoiceFormat objects are not equal
参考: https://docs.oracle.com/javase/9/docs/api/java/text/ChoiceFormat.html#applyPattern-java.lang.String-
相关用法
- Java ChoiceFormat format()用法及代码示例
- Java ChoiceFormat hashCode()用法及代码示例
- Java ChoiceFormat getLimits()用法及代码示例
- Java ChoiceFormat setChoices()用法及代码示例
- Java ChoiceFormat getFormats()用法及代码示例
- Java ChoiceFormat previousDouble()用法及代码示例
- Java ChoiceFormat applyPattern()用法及代码示例
- Java ChoiceFormat parse()用法及代码示例
- Java ChoiceFormat nextDouble(double)用法及代码示例
- Java ChoiceFormat nextDouble(double, boolean)用法及代码示例
- Java Map equals()用法及代码示例
- Java Set equals()用法及代码示例
- Java Short equals()用法及代码示例
- Java OffsetTime equals()用法及代码示例
- Java AbstractSet equals()用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 ChoiceFormat equals() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。