enfrptes

sendassignment@tutorspoint.com

Collection Interface Homework Help

Tutorspoint.com is an excellent site, which caters to all queries of programming students, regarding java assignments related to topics including Collection Interface homework help with quality solutions.

Since all the Java Assignment writing help is offered at reasonable rates, Tutorspoint expert service is highly recommended by students worldwide from many universities in USA America, Australia, Canada, Germany, Ireland, and Denmark.

 

What is the Collection interface in Java? 
The collection interface is the foundation upon which the collection framework is built. It declares the core methods that all collections will have.

A class cast exception is generated when objects are incompatible with another, Such as when an attempt is made to add an incompatible object to a collection. The following are methods defined in the collection interface.

 

Boolean add (object obj):

Adds an object to the invoking collection. Returns true if the object was added to the collection. Return false if the object is already a member of the collection, or if the collection does not allow duplicates.

 

Boolean add all (Collection c):

Adds all the elements of c to the invoking collection, Return true if the elements were added otherwise, return false.

 

Void clear ():

This removes all the elements from the invoking collection.

 

Boolean contains (object obj):

Return true if the object is an element of the invoking collection, otherwise, return false.

 

Boolean contains all (Collection c):

Return true if the invoking collections contain all elements of C, otherwise, return false.

 

Boolean equals (Object obj):

Returns true if the invoking collection and object are equal, otherwise, return false.

 

Int hash code ():

This returns the hash code for the invoking collection.

 

Boolean is empty ():

Returns true if the invoking collection is empty, otherwise, return false.

 

Boolean remove:

Remove one instance of the object from the invoking collection and returns true if the elements were removed, else return false.

 

Boolean removes all (Collection c):

Removes all the elements from the invoking collection except those in c. Returns true if the elements were removed, otherwise returns false.

 

Boolean retain all:

Removes all elements from the invoking collection except those in c. return true, if the elements were removed otherwise, return false.

 

Int size ():

Returns the number of elements held in the invoking collection.

 

Collection Interface Homework Help