Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Parse an long from the given string, falling back to the provided number in case of failure.
     * @param number String containing the long to be parsed.
     * @param fallback Number to return if parsing fails.
     * @return Either the parsed number or the fallback.
     */
    public static long safeParseLong(String number, long fallback) {
        try {
            return Long.parseLong(number);
        } catch (NumberFormatException nfe) {
            return fallback;
        }
    }
}