Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;
import java.util.regex.*;

public class Main {
    static final Matcher intMatch = Pattern.compile("[-+]?\\d+").matcher("");

    public static int[] parseIntList(String list) {
        if (list == null)
            return null;

        intMatch.reset(list);

        LinkedList<Integer> intList = new LinkedList<Integer>();
        while (intMatch.find()) {
            String val = intMatch.group();
            intList.add(Integer.valueOf(val));
        }

        int[] retArr = new int[intList.size()];
        Iterator<Integer> it = intList.iterator();
        int idx = 0;
        while (it.hasNext()) {
            retArr[idx++] = ((Integer) it.next()).intValue();
        }

        return retArr;
    }
}