Java list addAll null

java.util.Collections.addAll() Method


Advertisements

Previous Page
Next Page

Description

The addAll(Collection<? super T>, T..) method is used to add all of the specified elements to the specified collection.

Declaration

Following is the declaration for java.util.Collections.addAll() method.

public static <T> boolean addAll(Collection<? super T> c, T.. a)

Parameters

  • c This is the collection into which elements are to be inserted.

  • a This is the elements to insert into c

Return Value

The method call returns 'true' if the collection changed as a result of the call

Exception

  • UnsupportedOperationException This is thrown if c does not support the add method.

  • NullPointerException This is thrown if elements contains one or more null values and c does not support null elements.

  • IllegalArgumentException This is thrown if some aspect of a value in elements prevents it from being added to c.

Example

The following example shows the usage of java.util.Collections.addAll()

Live Demo
package com.tutorialspoint; import java.util.*; public class CollectionsDemo { public static void main(String args[]) { // create array list object List arrlist = new ArrayList(); // populate the list arrlist.add("A"); arrlist.add("B"); arrlist.add("C"); System.out.println("Initial collection value: "+arrlist); // add values to this collection boolean b = Collections.addAll(arrlist, "1","2","3"); System.out.println("Final collection value: "+arrlist); } }

Let us compile and run the above program, this will produce the following result.

Initial collection value: [A, B, C] Final collection value: [A, B, C, 1, 2, 3]
java_util_collections.htm
Page Not Found
Java list addAll null
×
Java list addAll null
Home
Jobs
Tools
Coding Ground
Current Affairs
UPSC Notes
Online Tutors
Whiteboard
Tutorix
Login
Java list addAll null
Categories
    • Academic Tutorials
    • Big Data & Analytics
    • Computer Programming
    • Computer Science
    • Databases
    • DevOps
    • Digital Marketing
    • Engineering Tutorials
    • Exams Syllabus
    • Famous Monuments
    • GATE Exams Tutorials
    • Latest Technologies
    • Machine Learning
    • Mainframe Development
    • Management Tutorials
    • Mathematics Tutorials
    • Microsoft Technologies
    • Misc tutorials
    • Mobile Development
    • Java Technologies
    • Python Technologies
    • SAP Tutorials
    • Programming Scripts
    • Selected Reading
    • Software Quality
    • Soft Skills
    • Telecom Tutorials
    • UPSC IAS Exams
    • Web Development
    • Sports Tutorials
    • XML Technologies
    • Multi-Language
    • Interview Questions
Q/A
Library
eBooks
Courses

404 - Page Not Found

404

We're sorry, but the page you were looking for doesn't exist.

Here are some useful links

  • Tutorials Library
  • Videos
  • Q/A
  • Coding Ground
  • Dev Tools
  • Contact Us
  • FAQ's


Extras

Mobile First

  • Java list addAll null
  • Java list addAll null
  • Java list addAll null

About us

  • Company
  • Our Team
  • Careers
  • Privacy Policy
  • Cookies Policy
  • Terms of use
  • Investors

Extra Links

  • Articles
  • Dev Tools
  • Free Graphics
  • File Conversion
  • Shared Tutorials
  • NetMeeting
  • Whiteboard

Contact Us

  • Address: 4th Floor, Incor9 Building, Kavuri Telangana 500081

  • Email: Click Here

  • Website: www.tutorialspoint.com

  • Facebook
  • Google+
  • Twitter
  • Linkedin
  • YouTube
Java list addAll null
  • Privacy Policy
  • Cookies Policy
  • Contact

© Copyright 2021. All Rights Reserved.

go