Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class RandomizeWords {
  5. public static void main(String[] args) {
  6. Scanner scanner=new Scanner(System.in);
  7.  
  8. String line=scanner.nextLine();
  9. String[] array = line.split(" ");
  10. Random ramdom =new Random();
  11. for (int i = 0; i < 1; i++) {
  12.  
  13. int firstIndex = ramdom.nextInt(array.length);
  14. int secomdIndex = ramdom.nextInt(array.length);
  15. String swapword=array[firstIndex];
  16. array[firstIndex]=array[secomdIndex];
  17. array[secomdIndex] = swapword;
  18.  
  19.  
  20. }
  21. for (int i = 0; i < array.length; i++) {
  22.  
  23. System.out.println(array[i]);
  24.  
  25. }
  26.  
  27.  
  28.  
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement