Java Integer Create toInteger(Object obj)

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

Description

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

Declaration

public static int toInteger(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w ww. jav a  2 s  .com*/
     * Get the integer value of this object, only if the object is an instance of Number
     *
     * @param obj the object to be converted
     * @return the integer value of the object, or 0 if it is not a number.
     */
    public static int toInteger(Object obj) {
        return (obj instanceof Number) ? ((Number) obj).intValue() : 0;
    }
}

Related

  1. toInteger(Object cell)
  2. toInteger(Object o)
  3. toInteger(Object o)
  4. toInteger(Object ob, Integer defaultInteger)
  5. toInteger(Object obj)
  6. toInteger(Object obj)
  7. toInteger(Object object)
  8. toInteger(Object object)
  9. toInteger(Object object, int defaultValue)