Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int toNumberWithDefault(String c, int def) {
        try {
            return Integer.parseInt(c);
        } catch (NumberFormatException e) {
            return def;
        }
    }

    public static String toNumberWithDefault(CharSequence c, String def) {
        return (c == null || c.length() == 0) ? def : c + "";
    }
}