Pass the List<String>
as a parameter to the constructor of a new ArrayList<Object>
.
List<Object> objectList = new ArrayList<Object>(stringList);
Any Collection
can be passed as an argument to the constructor as long as its type extends the type of the ArrayList
, as String
extends Object
. The constructor takes a Collection
, but List
is a subinterface of Collection
, so you can just use the List<String>
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…