Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static CharSequence[] split(CharSequence string, String pattern) {
        String[] parts = string.toString().split(pattern);
        List<CharSequence> res = new ArrayList<>();
        CharSequence temp = string;
        int pos = 0;
        for (String part : parts) {
            res.add(string.subSequence(pos, pos + part.length()));
            pos += part.length();
        }
        return res.toArray(new CharSequence[res.size()]);
    }
}