float.equals_Java Float類equals()方法與示例

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 class
public 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.0
ob2: 20.0
ob1.equals(ob2): false
Both objects are not equal

翻譯自: https://www.includehelp.com/java/float-class-equals-method-with-example.aspx

float.equals

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/378629.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378629.shtml
英文地址,請注明出處:http://en.pswp.cn/news/378629.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

01-基本配置與測試

一、開發環境 使用的是Anaconda 3,其中Python版本為3.6.3 首先,在Anaconda下的Scripts文件夾下打開命令框 使用pip install -U selenium安裝selenium 打開Jupiter Notebook,輸入from selenium import webdriver進行測試 不報錯即安裝成功 …

Opencv——查找并繪制凸包、凸包與輪廓的關系

定義 給定二維平面上的點集,凸包就是將最外層的點連接起來構成的凸多邊型。 理解物體形狀或輪廓的一 種比較有用的方法便是計算一個物體的凸包,然后計算其凸缺陷(convexity defects)。 檢測凸包 opencv自帶函數:convexHull() 參數解釋&a…

EF Code First 簡單的示例

一對多&#xff1a; public class Category {public Category(){Id GuidComb.GenerateComb();}public Guid Id { get; set; }public string Name { get; set; }public string Description { get; set; }public virtual IList<Topic> Topics { get; set; } }public class…

線程同步 - 整理

線程同步機制為線程協同工作而設計&#xff0c;windows系統中有多種機制可以用于線程同步&#xff0c;最常用的有下面幾種&#xff1a; 互斥對象(Mutex)時間對象(Event)信號量(Semaphore)臨界區(critical section)可等待計時器(waitable Timer)同步過程中兩個重要的概念是同步對…

智能車復工日記【N】:圖像處理——環島debug記錄(持續更新)

博主聯系方式: QQ:1540984562 QQ交流群:892023501 群里會有往屆的smarters和電賽選手,群里也會不時分享一些有用的資料,有問題可以在群里多問問。 Debug記錄 代碼以及思路整理:系列文章4.10號更新5.4號更新5.5號更新代碼以及思路整理: 【智能車Code review】——環島的判…

java接口并發衡量_java 后端設計高并發接口總結

如何設置高并發接口一、并發隊列的選擇二、請求接口的合理設計三、高并發下的數據安全3.1 超發的原因3.2 悲觀鎖思路3.3 FIFO隊列思路3.4 樂觀鎖思路一、并發隊列的選擇Java的并發包提供了三個常用的并發隊列實現&#xff0c;分別是&#xff1a;ArrayBlockingQueue、Concurrent…

兩倍---C++

【問題描述】給定n個不同的正整數&#xff0c;你的任務是計算這些數里面有多少個數對滿足&#xff1a;數對中一個數是另一個數的兩倍&#xff0c;比如給定1 4 3 2 9 7 18 22&#xff0c;得到的答案是3&#xff0c;因為2是1的兩倍&#xff0c;4是2的兩倍&#xff0c;18是9的兩倍…

java bitset_Java BitSet cardinality()方法與示例

java bitsetBitSet類cardinality()方法 (BitSet Class cardinality() method) cardinality() method is available in java.util package. cardinality()方法在java.util包中可用。 cardinality() method is used to return the cardinality (i.e. the number of bits is set t…

LeetCode: Merge k Sorted Lists

自己寫的太復雜了&#xff0c;一開始想的是給開始的lists頭們排序&#xff0c;然后從這個序列的第一個抽出來&#xff0c;然后再重新用二分法進行排序&#xff0c;不過這個方法large超時了&#xff0c;看了網上的發現還是用很土地方法用一個for循環從前兩個開始merge到最后&…

JAVA 取得當前目錄的路徑

在寫java程序時不可避免要獲取文件的路徑...總結一下,遺漏的隨時補上 1.可以在servlet的init方法里 String path getServletContext().getRealPath("/"); 這將獲取web項目的全路徑 例如 :E:/eclipseM9/workspace/tree/ tree是我web項目的根目錄 2.你也可以隨時在任意…

golang mysql curd_Go 語言操作 MySQL 之 CURD 操作

本文轉載于SegmentFault社區作者&#xff1a;Meng小羽MySQL 是目前開發中最常見的關系型數據庫&#xff0c;使用 Go 語言進行操控數據庫需要使用 Go 自帶database/sql和驅動go-sql-driver/mysql來實現。創建好 Go 項目&#xff0c;需要引用驅動依賴&#xff1a;go get -u githu…

02.1-元素定位(find)

常用的一些方法 一、導包 from selenium import webdriver二、打開火狐&#xff08;空白頁&#xff09; b webdriver.Firefox()三、跳轉到指定的網站 b.get(https://www.baidu.com/)四、將瀏覽器頁面最大化 b.maximize_window()五、通過F12可查看當前的貼吧為超鏈接形式 …

快速傅里葉變換(FFT)——按時間抽取DIT的基

目錄【1】前言1、DIF計算量2、利用性質改善【2】公式推導1、N 到 2*N/2a、分解原序列b、分解后的DFT變換c、一系列化簡操作之后d、蝶形信號流e、計算量總結2、N/2 到 2*N/4a、分解X2(k)序列b、蝶形信號流&#xff08;2列&#xff09;3、N/4 到 2*N/8a、蝶形信號流&#xff08;3…

Python字符串| 帶示例的format()方法

String.format()方法 (String.format() Method) format() method is used to format the string (in other words - we can say to achieve the functionality like printf() in C language). format()方法用于格式化字符串(換句話說&#xff0c;我們可以說實現了C語言中類似于…

PLSQL Developer使用技巧

1、PL/SQL Developer記住登陸密碼在使用PL/SQL Developer時&#xff0c;為了工作方便希望PL/SQL Developer記住登錄Oracle的用戶名和密碼&#xff1b;設置方法&#xff1a;PL/SQL Developer 7.1.2 ->tools->Preferences->Oracle->Logon History &#xff0c; “St…

3月份的總結

租房子找了個黑中介&#xff0c;各種扣錢&#xff0c;合租的違約了&#xff0c;押金不要了直接一走了之&#xff0c;水費我們承擔&#xff0c;中介這會兒又把責任推得一干二凈&#xff0c;還耍小聰明&#xff0c;非說我是兩個人住的&#xff0c;各種費用要交兩份。。。我一時氣…

快速傅里葉變換(FFT)——按頻率抽取DIF的基

目錄【1】回顧DIT【2】算法原理【3】運算特點【1】回顧DIT https://blog.csdn.net/qq_42604176/article/details/105559756 【2】算法原理 設序列點數&#xff1a;N2^M,M為正整數。將輸入序列按照前一半、后一半分開。&#xff08;并非按照奇偶分&#xff09; 由于&#xf…

02.2-元素定位(XPath)

XML路徑語言用來確定XML文檔中某部分位置的語言XPath用于在XML文檔中通過元素和屬性進行導航XPath遵守W3C標準XPath節點類型&#xff1a; 元素、屬性、文本、命名空間、指令處理、注釋、文檔 通過路徑表達式從XML文檔中選取節點或節點設置 表達式結果說明/xxx選取根節點xxx/xx…

android ImageView 之 android:scaleTye=

原文&#xff1a;http://juliaailse.iteye.com/blog/1409317 1、scaleType“matrix” 是保持原圖大小、從左上角的點開始&#xff0c;以矩陣形式繪圖。 2、scaleType“fitXY” 是將原圖進行橫方向&#xff08;即XY方向&#xff09;的拉伸后繪制的。 3、scaleType“fitStart…

acquire方法_Python鎖類| 帶有示例的acquire()方法

acquire方法Python Lock.acquire()方法 (Python Lock.acquire() Method) acquire() is an inbuilt method of the Lock class of the threading module in Python. acquisition()是Python中線程模塊的Lock類的內置方法。 This method is used to acquire a lock, either block…