I should add that you would need to use substring to allow the code to be more flexible and handle Strings of any length.
Type: Posts; User: Junky
I should add that you would need to use substring to allow the code to be more flexible and handle Strings of any length.
No you don't need a for loop.
String text = "abcd";
int index1 = 1; //change to be a random number
int index2 = 2; //change to be a random number
StringBuilder jumble = new StringBuilder();...
Why are you using a for loop? Since the task only requires you to swap 2 chars then I would generate 2 random numbers. If those numbers are greater than 0, less than length - 1 and not equal to each...