I am trying to create ArrayList of arrays with method Arrays.asList but I am struggling to achieve this goal when I have only one array to pass into the list.
List<String[]> notWithArrays = Arrays.asList(new String[] {"Slot"}); // compiler does not allow this
List<String[]> withArrays = Arrays.asList(new String[] {"Slot"},new String[] {"ts"}); // this is ok
The problem is that sometimes I have only one array to pass as argument and since it is only one iterable method asList creates List of strings out of it instead of required List<String[]>. Is there a way or method to make the list of arrays notWithArrays without having to create it manually?
Example of creating it manually:
List<String[]> withArraysManual = new ArrayList<>();
withArraysManual.add(new String[] {"Slot"});