If Arraylist cannot store elements ,how does string get passed into the Arraylist. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

If Arraylist cannot store elements ,how does string get passed into the Arraylist.

There's a yellow box that says ArrayList holds types of objects only and hence we need to pass in objects instead of elements. String being a data type ,how does it get passed into an ArrayList.

14th Jun 2018, 6:46 AM
Saayiaravind S
Saayiaravind S - avatar
2 Answers
+ 2
first of all you can pass String to arraylist because String is not primitive data type.char is. but for other data type like int or byte see this. https://www.sololearn.com/learn/432/?ref=app
14th Jun 2018, 6:59 AM
shobhit
shobhit - avatar
+ 1
Thank you shobhit
14th Jun 2018, 6:59 AM
Saayiaravind S
Saayiaravind S - avatar