0

I want to create a Arraylist which should contain Integers and Strings.. Is that possible?

https://code.sololearn.com/ceYgCYhS8GCd/?ref=app

9th Feb 2021, 4:13 PM
Edward
4 Respuestas
+ 2
But this is possible: fruit.add("Apple"); fruit.add("12311");
9th Feb 2021, 5:23 PM
JaScript
JaScript - avatar
+ 1
Its possible without inferring generics var array = new ArrayList(); or var array = new ArrayList<Object>(); also you can make an subimplementation to provide methods getting back with right values.... maybe with Optional class. Explore it!!
9th Feb 2021, 7:26 PM
David Ordás
David Ordás - avatar
0
no it's not possible
9th Feb 2021, 4:14 PM
Anthony Tannous
Anthony Tannous - avatar
0
var if it's java 10
10th Feb 2021, 5:52 AM
Anthony Tannous
Anthony Tannous - avatar