Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Arrays;
import java.util.Collection;

import java.util.Enumeration;

import java.util.Map;

public class Main {
    public static <T> void addAllKeys(Collection<T> c, Map<T, ?> map) {
        c.addAll(map.keySet());
    }

    public static <T> void addAll(Collection<T> c, T[] array) {
        if (isEmpty(array)) {
            return;
        }
        c.addAll(Arrays.asList(array));
    }

    public static <T> void addAll(Collection<T> c, Enumeration<T> enumeration) {
        while (enumeration.hasMoreElements()) {
            c.add(enumeration.nextElement());
        }
    }

    public static boolean isEmpty(Collection<?> c) {
        return c == null || c.isEmpty();
    }

    public static boolean isEmpty(Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    @SafeVarargs
    public static <T> boolean isEmpty(T... array) {
        return array == null || array.length == 0;
    }
}