Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.StringTokenizer;

public class Main {

    private static String[] tokenize(String str) {
        StringTokenizer tokenizer = new StringTokenizer(str);
        String[] arr = new String[tokenizer.countTokens()];
        int i = 0;
        while (tokenizer.hasMoreTokens()) {
            arr[i++] = tokenizer.nextToken();
        }
        return arr;
    }

    public static void main(String[] args) {
        String[] strs = tokenize("this is a test");
        for (String s : strs)
            System.out.println(s);
    }
}