checks for a null set and returns Collections.emptySet in that case. - Java java.util

Java examples for java.util:Collection Search

Description

checks for a null set and returns Collections.emptySet in that case.

Demo Code


//package com.java2s;

import java.util.Collections;

import java.util.Set;

public class Main {

    public static <T> Set<T> getSetValue(Set<T> set) {
        if (set == null) {
            return Collections.emptySet();
        }//  w w w.j a  v a 2  s  . com

        return set;
    }
}

Related Tutorials