MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

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

public class MainClass {
    public static void main(String args[]) {
        Pattern p = Pattern.compile("J2SE");

        String candidateString_1 = "j2se";
        String candidateString_2 = "J2SE ";
        String candidateString_3 = "J2SE";

        Matcher matcher_1 = p.matcher(candidateString_1);
        Matcher matcher_2 = p.matcher(candidateString_2);
        Matcher matcher_3 = p.matcher(candidateString_3);

        String msg = ":" + candidateString_1 + ": matches?: ";
        System.out.println(msg + matcher_1.matches());

        msg = ":" + candidateString_2 + ": matches?: ";
        System.out.println(msg + matcher_2.matches());

        msg = ":" + candidateString_3 + ": matches?: ";
        System.out.println(msg + matcher_3.matches());
    }
}
/*
    
*/