Java Float.equals(Object obj)

Syntax

Float.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use Float.equals(Object obj) method.


public class Main {
//from  w ww. ja va 2s  .  c  o m
   public static void main(String[] args) {
     Float obj1 = new Float("10");
     Float obj2 = new Float("10.0");
     System.out.print(obj1 + " = " + obj2);
     System.out.println(" ?  " + obj1.equals(obj2));

     obj1 = new Float("20");
     obj2 = new Float("6.000000");
     System.out.print(obj1 + " = " + obj2);
     System.out.println(" ?  " + obj1.equals(obj2));  
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable