In java we have inbuilt function to convert String array to List.
Syntax :-
Java String Array to List Example:
Syntax :-
Arrays.asList("Input string array");
package com.tutorial4u;
import java.util.Arrays;
import java.util.List;
public class ArrayToList {
public static void main(String[] args) {
String[] str = {"Tutorial4u","Ashish"};
List<String> list = Arrays.asList(str);
System.out.println(list);
}
}
Output: [Tutorial4u, Ashish]
No comments:
Post a Comment