Java tutorial
//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]; } }