Convert str to Integer object, return null if str is null. - Android java.lang

Android examples for java.lang:Integer

Description

Convert str to Integer object, return null if str is null.

Demo Code


public class Main{

    /**/*from   ww w  .  j a v a2  s . c  om*/
     * Convert str to Integer object, return null if str is null.
     * @param str
     * @return
     */
    public static Integer toInt(String str) {
        Integer result = null;
        if (str != null) {
            result = new Integer(str);
        }
        return result;
    }

}

Related Tutorials