MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

public class MainClass {
    public static void main(String[] args) {
        System.out.println(validatePhone("123-456-1111"));
    }

    public static boolean validatePhone(String phone) {
        return phone.matches("[1-9]\\d{2}-[1-9]\\d{2}-\\d{4}");
    } // end method validatePhone

}