Java tutorial
//package com.java2s; //License from project: Apache License import java.util.List; import java.util.NoSuchElementException; public class Main { public static <T> T third(List<T> list) { if (list.size() < 3) { throw new NoSuchElementException("Collection does not have a enough elements"); } return list.get(2); } }