Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] words = scanner.nextLine().split(" +");
- Random random = new Random();
- for (int i = 0; i < words.length; i++) {
- int firstIndex = random.nextInt(words.length);
- int secondIndex = random.nextInt(words.length);
- String swapWords = words[firstIndex];
- words[firstIndex] = words[secondIndex];
- words[secondIndex] = swapWords;
- }
- System.out.println(String.join(System.lineSeparator(), words));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement