Java - Write code to Check if a Collection is not Null And Has Size

Requirements

Write code to Check if a Collection is not Null And Has Size

Demo

//package com.book2s;
import java.util.Collection;

public class Main {
    public static void main(String[] argv) {
        Collection collection = java.util.Arrays.asList("asdf",
                "book2s.com");
        System.out.println(notNullAndHasSize(collection));
    }//from  w w w  . j ava  2 s.c om

    public static boolean notNullAndHasSize(Collection<?> collection) {
        return collection != null && collection.size() > 0;
    }
}