Using the toString method, we get a string, with the array values separated by commas. So, as the name of the method suggests, we are converting our array to string, where all the array elements would be separated by commas. We can use this method whenever required.
Let’s have a look at an example, which tries to demonstrate the use of the toString method.
Now, let’s have a look at the output of the above program.
As you can see in the output, we got a string, with all the array elements separated by commas. We can use this method whenever required.