Java Double Number Create toDouble(Object obj)

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

Description

Get the double 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 double value of the object, or 0.0d if it is not a number.

Declaration

public static double toDouble(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  w w  . ja va 2s  .  c  o m
     * Get the double value of this object, only if the object is an instance of Number
     *
     * @param obj the object to be converted
     * @return the double value of the object, or 0.0d if it is not a number.
     */
    public static double toDouble(Object obj) {
        return (obj instanceof Number) ? ((Number) obj).doubleValue() : 0.0d;
    }
}

Related

  1. toDouble(Object o)
  2. toDouble(Object o)
  3. toDouble(Object o)
  4. toDouble(Object o)
  5. toDouble(Object ob, Double defaultDouble)
  6. toDouble(Object obj)
  7. toDouble(Object obj)
  8. toDouble(Object obj)
  9. toDouble(Object obj)