Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static Integer asInteger(Object value) {
        return asInteger(value, 0);
    }

    public static Integer asInteger(Object value, int def) {
        if (value instanceof Number) {
            return Integer.valueOf(((Number) value).intValue());
        } else {
            try {
                return Integer.valueOf(value.toString());
            } catch (NumberFormatException ex) {
                return Integer.valueOf(def);
            }
        }
    }
}