Java Object to int castInt(Object o)

Here you can find the source of castInt(Object o)

Description

Casts the given object to an integer if applicable.

License

Open Source License

Parameter

Parameter Description
o Object to cast.

Return

The resulting integer.

Declaration

public static Integer castInt(Object o) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*  w  w  w  .ja  v  a2  s .  c o m*/
     * Casts the given object to an integer if applicable.
     * @param o Object to cast.
     * @return The resulting integer.
     */
    public static Integer castInt(Object o) {
        if (o instanceof Number) {
            return ((Number) o).intValue();
        }

        return null;
    }
}

Related

  1. castInt(Object o)
  2. castToInt(double[] aDouble)
  3. castToInt(final long value)
  4. castToInt(Object value)
  5. castToInteger(final String uid)