toArray method in Collections framework

The toArray method returns an array of all collection elements .There are two overloaded methods available in java Collections framework.



toArray method Returns Object array of  collection elements .

toArray method Collection , Set , List and Vector  contains the toArray method .

toArray(T[] t)

toArray method Returns a specific (like String)  array of  collection elements .

Collection , Set , List and Vector  interfaces have this method .



 <collection object>.toArray()  <collection object>.toArray(<array object>)

Example for toArray method:

Execution Result:

toArray method toArray method acts as a bridge between array-based  and collection-based APIs.

Related Posts :
PL/SQL Arrays and nested tables ( Collections )
addAll method in java Collections
removeAll method in Collections framework
containsAll method in Collections framework
retainAll method in Collections framework
   [will not be published]

^ <