Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static boolean isNumeric(Object num) {
        if ((num == null) || (num.toString().length() <= 0)) {
            return false;
        }
        String str = num.toString();
        if (str.length() <= 0) {
            return false;
        }
        if (str.matches("\\d{1,}")) {
            return true;
        }
        if (str.matches("^((-\\d+)|(0+))$")) {
            return true;
        }

        return (str.matches("^[0-9]+(.[0-9]{1,3})?$"));
    }
}