fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. String[] elementos = {"R","L","F","B","D","U","R'","L'","F'","B'","D'","U'","R2","L2","F2","B2","U2","D2"};
  14. String ranEle = getRandomValues(elementos, 10); //10 elementos aleatorios del array.
  15. System.out.println(ranEle);
  16.  
  17. }
  18.  
  19.  
  20. private static String getRandomValues(String[] valores, int cantidad){
  21. String res = "";
  22. for (int i = 0; i < cantidad; i++){
  23. res += valores[new Random().nextInt(valores.length)] + " ";
  24. }
  25. return res;
  26. }
  27.  
  28. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
L F F' R L' U F L' U' R'