Java Stack Peek peekOrNull(final Stack stack)

Here you can find the source of peekOrNull(final Stack stack)

Description

peek Or Null

License

Apache License

Declaration

public static <E> E peekOrNull(final Stack<? extends E> stack) 

Method Source Code

//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();
    }
}

Related

  1. peek(Stack stack, Class type)

    HOME | Copyright © www.java2s.com 2016