rootUser

List to Array

Jul 9th, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.63 KB | None | 0 0
  1. package sort;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import java.util.Random;
  7.  
  8. public class Sort
  9. {
  10.     public static void main(String[] args)
  11.     {
  12.         List<Double> list = new ArrayList();
  13.         Random random = new Random();
  14.         for(int i=0;i<5;i++)
  15.         {
  16.             double value = random.nextDouble();
  17.             list.add(value);
  18.         }
  19.         //System.out.println(Arrays.toString(list.toArray()));
  20.         Double[] array =   list.toArray(new Double[list.size()]);
  21.         System.out.println(Arrays.toString(array));
  22.        
  23.        
  24.        
  25.     }
  26.    
  27. }
Add Comment
Please, Sign In to add comment