博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
float.equals_Java Float类equals()方法与示例
阅读量:2530 次
发布时间:2019-05-11

本文共 1932 字,大约阅读时间需要 6 分钟。

float.equals

浮动类equals()方法 (Float class equals() method)

  • equals() method is available in java.lang package.

    equals()方法在java.lang包中可用。

  • equals() method is used to check equality or inequality of this Object against the given Object or in other words we can say this method is used to compare two objects.

    equals()方法用于检查该对象与给定对象的相等性或不相等性,换句话说,我们可以说该方法用于比较两个对象。

  • equals() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    equals()方法是一种非静态方法,仅可通过类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。

  • equals() method does not throw an exception at the time of comparing two Objects.

    在比较两个对象时, equals()方法不会引发异常。

Syntax:

句法:

public boolean equals(Object ob);

Parameter(s):

参数:

  • Object ob – represents the Object to compare with.

    对象ob –表示要比较的对象。

Return value:

返回值:

The return type of this method is boolean, it returns a boolean value, if both objects are same it returns true, else it returns false.

此方法的返回类型为boolean ,它返回一个布尔值,如果两个对象相同,则返回true,否则返回false。

Example:

例:

// Java program to demonstrate the example // of boolean equals(Object ob) method of // Float classpublic class EqualsOfFloatClass {
public static void main(String[] args) {
// Variables initialization Float ob1 = new Float(10.0f); Float ob2 = new Float(20.0f); // Display value1,value2 values System.out.println("ob1: " + ob1); System.out.println("ob2: " + ob2); // It compare two objects of Float type // by calling ob1.equals(ob2) boolean compare = ob1.equals(ob2); // Display result values System.out.println("ob1.equals(ob2): " + compare); if (compare == true) System.out.println("Both objects are equal"); else System.out.println("Both objects are not equal"); }}

Output

输出量

ob1: 10.0ob2: 20.0ob1.equals(ob2): falseBoth objects are not equal

翻译自:

float.equals

转载地址:http://vrxzd.baihongyu.com/

你可能感兴趣的文章
2018. 2.4 Java中集合嵌套集合的练习
查看>>
精通ASP.NET Web程序测试
查看>>
vue 根据不同属性 设置背景
查看>>
51Nod1601 完全图的最小生成树计数 Trie Prufer编码
查看>>
Codeforces 1110D. Jongmah 动态规划
查看>>
android驱动在win10系统上安装的心酸历程
查看>>
优雅的程序员
查看>>
oracle之三 自动任务调度
查看>>
Android dex分包方案
查看>>
ThreadLocal为什么要用WeakReference
查看>>
删除本地文件
查看>>
FOC实现概述
查看>>
base64编码的图片字节流存入html页面中的显示
查看>>
这个大学时代的博客不在维护了,请移步到我的新博客
查看>>
GUI学习之二十一——QSlider、QScroll、QDial学习总结
查看>>
nginx反向代理docker registry报”blob upload unknown"解决办法
查看>>
gethostbyname与sockaddr_in的完美组合
查看>>
kibana的query string syntax 笔记
查看>>
旋转变换(一)旋转矩阵
查看>>
thinkphp3.2.3 bug集锦
查看>>