Yes. We can do it this from three ways.
1. Arrays.asList(...)
e.g.,
String[] array = {"value1", "value2", "value3", "value4"};
List<String> arrayList = Arrays.asList(array);
2. Collections.addAll(...)
e.g., Collections.addAll(exampleList, "Value1", "Value2" , "Value3");
3. In spring framework---> CollectionUtils.arrayToList(...)
e.g.,
String [] array = {"value1", "value2", "value3", "value4"};
List<String> arrayList = CollectionUtils.arrayToList(array);
1. Arrays.asList(...)
e.g.,
String[] array = {"value1", "value2", "value3", "value4"};
List<String> arrayList = Arrays.asList(array);
2. Collections.addAll(...)
e.g., Collections.addAll(exampleList, "Value1", "Value2" , "Value3");
3. In spring framework---> CollectionUtils.arrayToList(...)
e.g.,
String [] array = {"value1", "value2", "value3", "value4"};
List<String> arrayList = CollectionUtils.arrayToList(array);
No comments:
Post a Comment