/* Recursion example: creating anagrams An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce other words, using all the original letters exactly once. This is a class that asks the user to enter a string and prints out all anagrams of that string, that is, all possible orderings (permutations), of the letters in the string. For example, the anagrams of "abc" are: abc, acb, bac, bca, cab, cba. The main method is makeAnagram() which is recursive. It works as follows: put every character in the string as first letter, and recursively find all anagrams of the remaining letters. Laura Toma, csci107 */ public class Anagram { public static void main (String args[]) { ReadStream r = new ReadStream(); //Read a string from the user System.out.print("Enter a string:"); String s = r.readString(); r.readLine(); //We convert the string to an array of characters. Basically //we want to freely change the letters in the string, and this //is not possible with class String, and is too cumbersome //with class StringBuffer. char[] text = new char[s.length()]; for (int i=0; i