Tuesday, 26 December 2017

How to Convert String Array to List in Java

In java we have inbuilt function to convert String array to List.


Syntax :-

   Arrays.asList("Input string array");


Java String Array to List Example:

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

No of Occurrence in Array

package com.tutorial4u; import java.util.HashMap; /************************************************************  No of Occurrence in Array...