fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Arrays;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. int[] x = {0,1,2,3};
  14. // int to double
  15. double[] doublesArray = Arrays.stream(x).asDoubleStream().toArray();
  16.  
  17. //int to string
  18. String[] stringArray = Arrays.stream(x).mapToObj(String::valueOf).toArray(String[]::new);
  19.  
  20. // string to double
  21. double[] doublesArrayFromString = Arrays.stream(stringArray).mapToDouble(Double::valueOf).toArray();
  22.  
  23. Arrays.stream(doublesArray).forEach(System.out::println);
  24. Arrays.stream(stringArray).forEach(System.out::println);
  25. Arrays.stream(doublesArrayFromString).forEach(System.out::println);
  26. }
  27. }
Success #stdin #stdout 0.14s 4386816KB
stdin
Standard input is empty
stdout
0.0
1.0
2.0
3.0
0
1
2
3
0.0
1.0
2.0
3.0