Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String nthElement(final String s, final String separator, final int index) {
        final String[] list = s.split(separator);
        if (list.length <= 0)
            return null;
        if (index >= list.length)
            throw new IndexOutOfBoundsException("Could not get element " + index + " in " + s);
        return list[list.length - 1];
    }
}