![]() |
VOOZH | about |
In Java, the toString() method is defined in the Object class and is inherited by all the Java classes. It is used to return a string representation of an object. The AbstractCollection class is a part of the Java Collections Framework, which overrides this method to provide a string representation of the collection.
Example 1: This example demonstrates how the toString() method of AbstractCollection returns a string representation of the collection's elements.
[Geeks, for, Geeks]
public String toString()
Example 2: This example demonstrates the working of toString() method.
[10, 20, 30, 40]