Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int toInteger(String number, String pre) {
        int newNumber = 0;
        if (isNumber(number)) {
            newNumber = Integer.parseInt(number);
        } else {
            newNumber = Integer.parseInt(pre);
        }
        return newNumber;
    }

    public static boolean isNumber(String string) {
        try {
            Long.parseLong(string);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}