I am trying to get a String Collection in my Java code, so i'm trying something like this:
Collection c = new String[]{};
But i get this error: incompatible types: String[] cannot be converted to Collection
.
Is there a way to convert String[] into Collection without doing something like this:
var array = new String[]{"Apple", "Banana"};
var arrayList = new ArrayList<String>();
for (String fruit : array) {
arrayList.add(fruit);
}
Collection c = arrayList;