Java Float Number Create toFloat(Object obj)

Here you can find the source of toFloat(Object obj)

Description

Get the float value of this object, only if the object is an instance of Number

License

Open Source License

Parameter

Parameter Description
obj the object to be converted

Return

the float value of the object, or 0.0f if it is not a number.

Declaration

public static float toFloat(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w ww  .j av  a2s . c o m
     * Get the float value of this object, only if the object is an instance of Number
     *
     * @param obj the object to be converted
     * @return the float value of the object, or 0.0f if it is not a number.
     */
    public static float toFloat(Object obj) {
        return (obj instanceof Number) ? ((Number) obj).floatValue() : 0.0f;
    }
}

Related

  1. toFloat(Object o)
  2. toFloat(Object o)
  3. toFloat(Object ob, Float defaultFloat)
  4. toFloat(Object obj)
  5. toFloat(Object obj)
  6. toFloat(Object obj)
  7. toFloat(Object obj, String pattern)
  8. toFloat(Object rawColor)
  9. toFloat(Object v)