Write a Java Program to convert a string into an arraylist.
Click Here to View the Solution!
Click Here to View the Output!
Click Here to View the Explanation!
- In this program, first a String called
stris created which contains a sequence of characters separated by commas in between them.
- This string
stris then printed onto the screen.
Stris then split using the
,passed as its parameter. This means that the string is split where comma is present and the characters before the split are stored as an element in the
String array arr.
array arris then converted into an
asList()method of the Arrays class, where
arris passed as a parameter.
Languagesis then printed onto the screen.