Building the Right Environment to Support , Machine Learning and Deep Learning

The java.util.Arrays class has an asList method to the argument into a . This will be handy when there are large amounts of information that you need to enumerate.

import java.util.Arrays;
import java.util.List;

public class ConvertArrayToList
   public static void main(String args[])
      ConvertArrayToList convertArrayToList = new ConvertArrayToList();
   private void proceed()
      //String array containing the  days
      String daysOfWeek[] =  {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
      List listOfWeekDays =  Arrays.asList(daysOfWeek); //method to convert into a list
      System.out.println(" days: "+listOfWeekDays);


Expected output:

[root@mypc]# java ConvertArrayToList
Week days: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]



Visit the DevX Tip Bank


Source link
thanks you RSS link


Please enter your comment!
Please enter your name here