Shuffle the characters of a string in Java

This is a program which accepts a string using the BufferdReader and InputStreamReader class, and then shuffle the characters present inside the string and generate a new string which is displayed in the console. Basically the characters of the string are stored in a Character List using the for each loop. Then the characters in that list is randomly removed and appended in a StringBuilder object output.

Screenshots [Demo]

The Code:

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
class Brain
public static void main(String []as)throws IOException
BufferedReader br=new BufferedReader(new InputStreamReader(;
System.out.print("Enter The String: ");
String input=br.readLine();
List<Character> characters = new ArrayList<Character>();
for(char c:input.toCharArray()){
StringBuilder output = new StringBuilder(input.length());
int randPicker = (int)(Math.random()*characters.size());
System.out.println("THe Shuffled is : "+output.toString());

Founds Bugs, or want to give suggestions,
Drop them here !

Related posts

Leave a Comment