Here you can find the source of peekOrNull(final Stack extends E> stack)
public static <E> E peekOrNull(final Stack<? extends E> stack)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Stack; public class Main { public static <E> E peekOrNull(final Stack<? extends E> stack) { return !isEmpty(stack) ? stack.peek() : null; }/* w w w. ja v a 2s.c o m*/ public static boolean isEmpty(final Collection<?> collection) { return (collection == null) || collection.isEmpty(); } }