Java CopyOnWriteArrayList clone() Method

The clone() method of Java CopyOnWriteArrayList class returns a shallow copy of this list. In this method, elements themselves are not copied.

Syntax:

Returns:

This method returns a clone of this list.

Example 1

Test it Now

Output:

Clone List is : [1, 2, 1, 4, 5, 3, 3, 8]

Example 2

Test it Now

Output:

Clone List is : []

Example 3

Test it Now

Output:

Clone List is : [Tom, Harry, John, John, John, Jerry]

Example 4

Test it Now

Output:

Clone List is : []





Latest Courses