MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

/*
 * Output:
Next token: www
Next token: java2s
Next token: com
Next token: java
Next token: javascript
Next token: API
Next token: example
 * */

import java.util.regex.Pattern;

public class MainClass {
    public static void main(String args[]) {

        Pattern pat = Pattern.compile("[ ,.!]");

        String strs[] = pat.split("www.java2s.com java javascript API example.");

        for (int i = 0; i < strs.length; i++)
            System.out.println("Next token: " + strs[i]);

    }
}