Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class RandomizeWords {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- String line=scanner.nextLine();
- String[] array = line.split(" ");
- Random ramdom =new Random();
- for (int i = 0; i < 1; i++) {
- int firstIndex = ramdom.nextInt(array.length);
- int secomdIndex = ramdom.nextInt(array.length);
- String swapword=array[firstIndex];
- array[firstIndex]=array[secomdIndex];
- array[secomdIndex] = swapword;
- }
- for (int i = 0; i < array.length; i++) {
- System.out.println(array[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement