Here you can find the source of elementFail(Queue
public static void elementFail(Queue<Object> q)
//package com.java2s; //License from project: Open Source License import java.util.NoSuchElementException; import java.util.Queue; public class Main { public static void elementFail(Queue<Object> q) { try {/*from ww w. ja v a 2 s.c o m*/ q.element(); throw new RuntimeException("Exception should have thrown"); } catch (NoSuchElementException e) { // expected } } }