Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static final String MasterCardCreditCardPattern = "^5[1-5][0-9]{14}$";

    private static boolean isMasterCard(String creditCardNumber) {

        Pattern pattern = Pattern.compile(MasterCardCreditCardPattern);
        Matcher matcher = pattern.matcher(creditCardNumber);
        return matcher.find();
    }
}