add All varied length object array to Collection - Java Collection Framework

Java examples for Collection Framework:Array Length

Description

add All varied length object array to Collection

Demo Code


//package com.java2s;

import java.util.Collection;

public class Main {
    public static void main(String[] argv) {
        Collection c = java.util.Arrays.asList("asdf", "java2s.com");
        Object objs = "java2s.com";
        System.out.println(addAll(c, objs));
    }/*w  w w  .  j a va  2  s .  c o  m*/

    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static boolean addAll(Collection c, Object... objs) {
        boolean result = false;
        for (Object obj : objs) {
            result |= c.add(obj);
        }
        return result;
    }
}

Related Tutorials