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 phoneNumberRule(String phone) {
        boolean result = false;
        long min = 13000000000L;
        long max = 18999999999L;
        long data = 0;
        try {
            data = Long.parseLong(phone);
        } catch (NumberFormatException e) {
            result = false;
            e.printStackTrace();
        }
        if (phone.length() != 11)
            result = false;
        else if (data < min || data > max)
            result = false;
        else
            result = true;
        return result;
    }
}