Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.text.TextUtils;

public class Main {

    public static int obj2Int(Object obj) {
        if (obj == null)
            return 0;
        return str2Int(obj.toString(), 0);
    }

    public static int str2Int(String str, int defValue) {
        try {
            if (TextUtils.isEmpty(str))
                return defValue;
            return Integer.parseInt(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return defValue;
    }
}