AbstractCollection.toString(): This method is available in java.util.ArrayList class of Java.
Syntax:
String java.util.AbstractCollection.toString()
This method returns a string representation of this collection.
Parameters: NA
Returns: a string representation of this collection.
Exceptions: NA
Approach
Java
import java.util.ArrayList;public class ArrayListtoString {public static void main(String[] args) {ArrayList<Integer> arr = new ArrayList<>();arr.add(1);arr.add(2);arr.add(3);System.out.println(arr.toString());}}
Output:
[1, 2, 3]
No comments:
Post a Comment