Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

public class Main {
    /**
     * *
     * Get size of Collection and NullPointerException safe
     *
     * @param collection
     * @return -1 if collction is null then else return collection's size
     */
    public static int getSize(Collection collection) {
        if (collection == null) {
            return -1;
        }
        return collection.size();
    }
}